|
17 | 17 | uses: dependabot/fetch-metadata@v2
|
18 | 18 | with:
|
19 | 19 | github-token: "${{ secrets.GITHUB_TOKEN }}"
|
| 20 | + - uses: actions/checkout@v5 |
| 21 | + with: |
| 22 | + fetch-depth: 2 |
| 23 | + if: steps.metadata.outputs.update-type == 'version-update:semver-patch' |
| 24 | + - name: Check if package-lock.json has been changed |
| 25 | + if: steps.metadata.outputs.update-type == 'version-update:semver-patch' |
| 26 | + id: npm |
| 27 | + env: |
| 28 | + PR_URL: ${{github.event.pull_request.html_url}} |
| 29 | + GH_TOKEN: ${{secrets.GITHUB_TOKEN}} |
| 30 | + run: | |
| 31 | + if ! git diff --quiet HEAD~1.. -- package-lock.json; then |
| 32 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 33 | + echo "changed=true, checking out $PR_URL to allow amend" |
| 34 | + gh pr checkout "$PR_URL" |
| 35 | + fi |
| 36 | + - name: Setup node if necessary |
| 37 | + if: steps.npm.outputs.changed != '' |
| 38 | + uses: actions/setup-node@v4 |
| 39 | + with: |
| 40 | + node-version: 20.x |
| 41 | + cache: npm |
| 42 | + - name: Re-generate and commit dist/ if changed |
| 43 | + id: amend |
| 44 | + if: steps.npm.outputs.changed != '' |
| 45 | + run: | |
| 46 | + npm ci |
| 47 | + npm run prepare |
| 48 | + if ! git diff --quiet dist/*/index.js; then |
| 49 | + echo "dist/ changed, amending last commit" |
| 50 | + export $(git log -1 --pretty=format:'GIT_COMMITTER_NAME=%cn GIT_COMMITTER_EMAIL=%ce GIT_AUTHOR_NAME=%an GIT_AUTHOR_EMAIL=%ae') |
| 51 | + git fetch --unshallow |
| 52 | + echo "Before amend:" && git show --name-only --pretty= |
| 53 | + git commit --amend --no-edit --no-reset-author -- dist/*/index.js |
| 54 | + echo "After amend:" && git show --name-only --pretty= |
| 55 | + git push --force-with-lease origin HEAD |
| 56 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 57 | + fi |
20 | 58 | - name: Auto-merge Patch PRs
|
21 | 59 | if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
|
22 | 60 | run: gh pr merge --auto --merge "$PR_URL"
|
|
0 commit comments