Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d8c5063

Browse files
chore(dependabot): regenerate and commit dist/ (#257)
1 parent 267a8a9 commit d8c5063

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

.github/workflows/dependabot.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,44 @@ jobs:
1717
uses: dependabot/fetch-metadata@v2
1818
with:
1919
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
2058
- name: Auto-merge Patch PRs
2159
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
2260
run: gh pr merge --auto --merge "$PR_URL"

0 commit comments

Comments
 (0)