Skip to content

Commit 396a172

Browse files
authored
Merge pull request #23 from dscho/npm-run-package-on-dependabot-prs
ci: automagically repackage when Dependabot updates a dependency
2 parents f9e3010 + cc141fa commit 396a172

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: 'npm run prepare'
2+
# Main use case: repackage when Dependabot updates a dependency
3+
on:
4+
push:
5+
branches:
6+
- 'dependabot/npm_and_yarn/**'
7+
workflow_dispatch:
8+
inputs:
9+
branch:
10+
description: 'Process this branch'
11+
required: false
12+
type: string
13+
14+
jobs:
15+
npm-run-prepare-and-push: # make sure build/ci work properly
16+
runs-on: ubuntu-latest
17+
if: github.event_name == 'workflow_dispatch' || github.event.repository.owner.login == 'git-for-windows'
18+
environment: git-for-windows-ci-push
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
repository: ${{ github.event.repository.full_name }}
23+
ref: ${{ inputs.branch }}${{ github.event.ref }}
24+
token: ${{ secrets.GIT_FOR_WINDOWS_CI_PUSH }}
25+
- run: npm ci
26+
- run: npm run prepare
27+
- run: git diff-files
28+
- run: npm run lint
29+
- run: npm run test
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 prepare' -- 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)