Skip to content

Commit

Permalink
Merge pull request #80 from codecrafters-io/gen-fixtures-ci
Browse files Browse the repository at this point in the history
Add CI job for fixture regeneration
  • Loading branch information
ryan-gang authored Dec 27, 2024
2 parents e8e4d45 + 77f8b0b commit 97b8bda
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/fixtures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Trigger Fixture Regeneration

on:
pull_request:
types:
- labeled

permissions:
contents: write
pull-requests: write

jobs:
trigger_pipeline:
if: github.event.label.name == 'regenerate-fixtures'
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.RYAN_FIXTURE_GEN_PAT }}

- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.22.x

- uses: actions-ecosystem/action-create-comment@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
body: |
Triggered a [Github Actions](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) job to update fixtures.
- uses: actions-ecosystem/action-remove-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: regenerate-fixtures

- name: Regenerate Fixtures
run: CODECRAFTERS_RECORD_FIXTURES=true make test

- name: Update Fixtures
run: |
git config --global user.email "[email protected]"
git config --global user.name "Ryan Gang"
git remote set-url origin https://ryan-gang:${{ secrets.RYAN_FIXTURE_GEN_PAT }}@github.com/codecrafters-io/shell-tester.git
git fetch origin ${{ github.head_ref }}
git checkout ${{ github.head_ref }}
git diff --quiet || (git add . && git commit -m "ci: add regenerated fixtures" && git push)

0 comments on commit 97b8bda

Please sign in to comment.