|
| 1 | +name: Sync Webpack |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Run every 24 hours at 04:00 UTC |
| 6 | + - cron: "0 4 * * *" |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + sync: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 18 | + |
| 19 | + - name: Get latest webpack commit |
| 20 | + id: latest |
| 21 | + run: | |
| 22 | + LATEST=$(git ls-remote https://github.com/webpack/webpack.git refs/heads/main | cut -f1) |
| 23 | + CURRENT=$(cat HEAD_COMMIT) |
| 24 | + echo "latest=$LATEST" >> "$GITHUB_OUTPUT" |
| 25 | + echo "current=$CURRENT" >> "$GITHUB_OUTPUT" |
| 26 | + echo "Latest webpack commit: $LATEST" |
| 27 | + echo "Current pinned commit: $CURRENT" |
| 28 | +
|
| 29 | + - name: Check for changes |
| 30 | + id: check |
| 31 | + run: | |
| 32 | + if [ "${{ steps.latest.outputs.latest }}" = "${{ steps.latest.outputs.current }}" ]; then |
| 33 | + echo "changed=false" >> "$GITHUB_OUTPUT" |
| 34 | + echo "No changes detected, skipping sync." |
| 35 | + else |
| 36 | + echo "changed=true" >> "$GITHUB_OUTPUT" |
| 37 | + echo "New webpack commit detected, syncing." |
| 38 | + fi |
| 39 | +
|
| 40 | + - name: Checkout webpack |
| 41 | + if: steps.check.outputs.changed == 'true' |
| 42 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 43 | + with: |
| 44 | + repository: webpack/webpack |
| 45 | + ref: ${{ steps.latest.outputs.latest }} |
| 46 | + path: webpack |
| 47 | + |
| 48 | + - name: Setup Node.js |
| 49 | + if: steps.check.outputs.changed == 'true' |
| 50 | + uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 |
| 51 | + with: |
| 52 | + node-version: lts/* |
| 53 | + cache: "npm" |
| 54 | + |
| 55 | + - name: Install dependencies |
| 56 | + if: steps.check.outputs.changed == 'true' |
| 57 | + run: npm ci |
| 58 | + |
| 59 | + - name: Update HEAD_COMMIT |
| 60 | + if: steps.check.outputs.changed == 'true' |
| 61 | + run: echo "${{ steps.latest.outputs.latest }}" > HEAD_COMMIT |
| 62 | + |
| 63 | + - name: Regenerate docs |
| 64 | + if: steps.check.outputs.changed == 'true' |
| 65 | + run: npm run generate-docs |
| 66 | + |
| 67 | + - name: Commit and push |
| 68 | + if: steps.check.outputs.changed == 'true' |
| 69 | + run: | |
| 70 | + git config user.name "github-actions[bot]" |
| 71 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 72 | + git add HEAD_COMMIT pages/ |
| 73 | + git commit -m "chore: sync webpack docs to $(echo ${{ steps.latest.outputs.latest }} | cut -c1-7)" |
| 74 | + git push |
0 commit comments