Migrate Repo to Github Actions #630
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run test file with command: | |
# act pull_request -e testdata/act/pull-request.json | |
name: Test and Generate Docs | |
on: pull_request | |
jobs: | |
Run_Go_Tests: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install pre-commit | |
run: | | |
python -m pip install --upgrade pip | |
pip install pre-commit | |
- name: Run pre-commit hooks | |
run: pre-commit run --all-files | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.22 | |
- name: Install dependencies | |
run: go mod tidy | |
- name: Run tests | |
run: go test ./... -coverprofile=coverage.out | |
Run_E2E_Tests: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Find LaunchDarkly feature flags in diff | |
uses: ./ # Uses an action in the root directory | |
id: find-flags | |
with: | |
project-key: demo-dan-042021-2 | |
environment-key: development | |
access-token: ${{ secrets.LD_ACCESS_TOKEN_WRITER }} | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
base-uri: https://app.launchdarkly.com | |
max-flags: 200 | |
create-flag-links: true | |
- name: Find flags summary | |
run: | | |
echo "flags addded or modified ${{ steps.find-flags.outputs.modified-flags-count }}" | |
echo "flags removed ${{ steps.find-flags.outputs.removed-flags-count }}" | |
- name: Added or modified flags | |
if: steps.find-flags.outputs.any-modified == 'true' | |
run: | | |
for flag in ${{ steps.find-flags.outputs.modified-flags }}; do | |
echo "$flag was added or modified" | |
done | |
- name: Removed flags | |
if: steps.find-flags.outputs.any-removed == 'true' | |
run: | | |
for flag in ${{ steps.find-flags.outputs.removed-flags }}; do | |
echo "$flag was removed" | |
done | |
- name: Add label | |
if: ${{ steps.find-flags.outputs.any-changed == 'true' && github.actor != 'dependabot[bot]' }} | |
run: gh pr edit $PR_NUMBER --add-label ld-flags | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PR_NUMBER: ${{ github.event.pull_request.number }} | |
- name: Remove label | |
if: ${{ steps.find-flags.outputs.any-changed == 'false' && github.actor != 'dependabot[bot]' }} | |
run: gh pr edit $PR_NUMBER --remove-label ld-flags | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PR_NUMBER: ${{ github.event.pull_request.number }} | |
Generate_Docs: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install pre-commit | |
run: | | |
python -m pip install --upgrade pip | |
pip install pre-commit | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18.8.0' | |
- name: Install action-docs | |
run: npm install action-docs | |
- name: Run pre-commit for GitHub Actions Docs | |
run: pre-commit run -a github-action-docs | |