|
| 1 | +name: Extract Snippets |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + paths: |
| 8 | + - "samples/**" |
| 9 | + - "scripts/**" |
| 10 | + - "placeholder-map.yaml" |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + |
| 16 | +jobs: |
| 17 | + validate: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - uses: actions/setup-node@v4 |
| 23 | + with: |
| 24 | + node-version: "22" |
| 25 | + |
| 26 | + - name: Enable Corepack |
| 27 | + run: corepack enable |
| 28 | + |
| 29 | + - name: Install dependencies |
| 30 | + run: yarn install --immutable |
| 31 | + |
| 32 | + - name: Aggregate manifests |
| 33 | + working-directory: scripts |
| 34 | + run: yarn aggregate |
| 35 | + |
| 36 | + - name: Extract snippets |
| 37 | + working-directory: scripts |
| 38 | + run: yarn extract |
| 39 | + |
| 40 | + - name: Validate structure |
| 41 | + working-directory: scripts |
| 42 | + run: yarn validate |
| 43 | + |
| 44 | + - name: Verify no drift (PR only) |
| 45 | + if: github.event_name == 'pull_request' |
| 46 | + run: | |
| 47 | + git diff --exit-code snippets.json snippet-manifest.yaml || \ |
| 48 | + (echo "::error::Extracted artifacts are out of date. Run 'cd scripts && yarn all' and commit the results." && exit 1) |
| 49 | +
|
| 50 | + commit: |
| 51 | + needs: validate |
| 52 | + if: github.event_name == 'push' |
| 53 | + runs-on: ubuntu-latest |
| 54 | + permissions: |
| 55 | + contents: write |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v4 |
| 58 | + |
| 59 | + - uses: actions/setup-node@v4 |
| 60 | + with: |
| 61 | + node-version: "22" |
| 62 | + |
| 63 | + - name: Enable Corepack |
| 64 | + run: corepack enable |
| 65 | + |
| 66 | + - name: Install dependencies |
| 67 | + run: yarn install --immutable |
| 68 | + |
| 69 | + - name: Aggregate manifests |
| 70 | + working-directory: scripts |
| 71 | + run: yarn aggregate |
| 72 | + |
| 73 | + - name: Extract snippets |
| 74 | + working-directory: scripts |
| 75 | + run: yarn extract |
| 76 | + |
| 77 | + - name: Check for changes |
| 78 | + id: diff |
| 79 | + run: | |
| 80 | + git diff --quiet snippets.json snippet-manifest.yaml || echo "changed=true" >> "$GITHUB_OUTPUT" |
| 81 | +
|
| 82 | + - name: Commit updated artifacts |
| 83 | + if: steps.diff.outputs.changed == 'true' |
| 84 | + run: | |
| 85 | + git config user.name "github-actions[bot]" |
| 86 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 87 | + git add snippets.json snippet-manifest.yaml |
| 88 | + git commit -m "chore: update extracted snippets and manifest" |
| 89 | + git push |
| 90 | +
|
| 91 | + # - name: Notify ciam-core of snippet changes |
| 92 | + # if: steps.diff.outputs.changed == 'true' |
| 93 | + # run: | |
| 94 | + # gh api repos/SecureAuthCorp/ciam-core/dispatches \ |
| 95 | + # -f event_type=quickstart-snippets-updated \ |
| 96 | + # -f 'client_payload[sha]=${{ github.sha }}' |
| 97 | + # env: |
| 98 | + # GH_TOKEN: ${{ secrets.CIAM_CORE_DISPATCH_TOKEN }} |
0 commit comments