Skip to content

Commit a4382e3

Browse files
authored
Merge pull request #304 from dscho/automatically-repackage-upon-dependabot-updates
ci: Automagically repackage when Dependabot updates a dependency
2 parents 981d32a + bed5812 commit a4382e3

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

.github/workflows/npm-run-package.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: 'npm run package'
2+
# Main use case: repackage when Dependabot updates a dependency
3+
on:
4+
push:
5+
branches:
6+
- 'dependabot/**'
7+
workflow_dispatch:
8+
inputs:
9+
branch:
10+
description: 'Process this branch'
11+
required: false
12+
type: string
13+
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
npm-run-package-and-push: # make sure build/ci work properly
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v2
22+
with:
23+
ref: ${{ inputs.branch }}
24+
- run: npm ci
25+
- run: npm run build
26+
- run: npm run lint
27+
- run: npm run format && git diff-files
28+
- run: npm run test
29+
- run: npm run package
30+
- name: check if commit & push is needed
31+
id: check
32+
run: |
33+
git add -u -- dist/ &&
34+
git diff-index --cached --exit-code HEAD -- ||
35+
echo "::set-output name=need-to-commit::yes"
36+
- name: commit & push
37+
if: steps.check.outputs.need-to-commit == 'yes'
38+
run: |
39+
git config user.name "${{github.actor}}" &&
40+
git config user.email "${{github.actor}}@users.noreply.github.com" &&
41+
git commit -m 'npm run build && npm run package' -- dist/ &&
42+
git update-index --refresh &&
43+
git diff-files --exit-code &&
44+
git diff-index --cached --exit-code HEAD -- &&
45+
git push

0 commit comments

Comments
 (0)