|
| 1 | +--- |
| 2 | +name: Regenerate derived files |
| 3 | +on: # yamllint disable-line rule:truthy |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - "src/valuesets/schema/**/*.yaml" |
| 8 | + - "src/valuesets/schema/*.yaml" |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +permissions: {} |
| 12 | + |
| 13 | +jobs: |
| 14 | + regen: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + permissions: |
| 18 | + contents: write |
| 19 | + pull-requests: write |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + |
| 27 | + - name: Install uv |
| 28 | + uses: astral-sh/setup-uv@v6 |
| 29 | + with: |
| 30 | + enable-cache: true |
| 31 | + cache-dependency-glob: "uv.lock" |
| 32 | + |
| 33 | + - name: Set up Python |
| 34 | + uses: actions/setup-python@v5 |
| 35 | + with: |
| 36 | + python-version: "3.13" |
| 37 | + |
| 38 | + - name: Install just |
| 39 | + run: uv tool install rust-just |
| 40 | + |
| 41 | + - name: Install dependencies |
| 42 | + run: uv sync --group dev --no-progress |
| 43 | + |
| 44 | + - name: Regenerate derived files |
| 45 | + run: | |
| 46 | + just gen-project |
| 47 | + just gen-doc |
| 48 | +
|
| 49 | + - name: Check for changes |
| 50 | + id: changes |
| 51 | + run: | |
| 52 | + git add -A |
| 53 | + if git diff --cached --quiet; then |
| 54 | + echo "changed=false" >> "$GITHUB_OUTPUT" |
| 55 | + else |
| 56 | + echo "changed=true" >> "$GITHUB_OUTPUT" |
| 57 | + fi |
| 58 | +
|
| 59 | + - name: Close previous regen PRs |
| 60 | + if: steps.changes.outputs.changed == 'true' |
| 61 | + env: |
| 62 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 63 | + run: | |
| 64 | + gh pr list \ |
| 65 | + --label "automated-regen" \ |
| 66 | + --state open \ |
| 67 | + --json number \ |
| 68 | + --jq '.[].number' \ |
| 69 | + | while read -r pr; do |
| 70 | + gh pr close "$pr" --comment "Superseded by a newer regeneration run." |
| 71 | + done |
| 72 | +
|
| 73 | + - name: Create pull request |
| 74 | + if: steps.changes.outputs.changed == 'true' |
| 75 | + env: |
| 76 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + run: | |
| 78 | + BRANCH="auto/regen-derived-$(date +%Y%m%d-%H%M%S)" |
| 79 | + git config user.name "github-actions[bot]" |
| 80 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 81 | + git checkout -b "$BRANCH" |
| 82 | + git commit -m "Regenerate derived files from schema changes" |
| 83 | + git push -u origin "$BRANCH" |
| 84 | +
|
| 85 | + gh label create "automated-regen" \ |
| 86 | + --description "PRs created by the regen-derived workflow" \ |
| 87 | + --color "c5def5" \ |
| 88 | + --force |
| 89 | +
|
| 90 | + gh pr create \ |
| 91 | + --title "Regenerate derived files" \ |
| 92 | + --label "automated-regen" \ |
| 93 | + --body "$(cat <<'EOF' |
| 94 | + Automated regeneration of derived files after schema changes. |
| 95 | +
|
| 96 | + Updated by running: |
| 97 | + ``` |
| 98 | + just gen-project |
| 99 | + just gen-doc |
| 100 | + ``` |
| 101 | +
|
| 102 | + Please review the diffs before merging. |
| 103 | + EOF |
| 104 | + )" |
0 commit comments