Skip to content

Commit e14b41b

Browse files
authored
chore(cicd): package action should be triggered on PR push (#485)
* fix package action * update * avoid endless loop hell * push commit only on dependabot pr * . * .. * change job name back * blah * to PR not to master
1 parent df96430 commit e14b41b

File tree

1 file changed

+32
-20
lines changed

1 file changed

+32
-20
lines changed

.github/workflows/package.yml

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
1+
name: Package
2+
3+
# When a pull request is opened/reopened or when the head branch of the pull request is updated.
14
on:
2-
push:
3-
branches:
4-
- master
5+
pull_request:
56

6-
name: Package
77

88
jobs:
9-
check:
9+
build:
10+
if: github.event.commits[0].author.name != 'GitHub Actions'
1011
name: Package distribution file
1112
runs-on: ubuntu-latest
1213
steps:
13-
- name: Checkout
14-
uses: actions/checkout@v2
15-
with:
16-
ref: master
17-
- name: Package
18-
run: |
19-
npm ci
20-
npm test
21-
npm run package
22-
- name: Commit
23-
run: |
24-
git config --global user.name "GitHub Actions"
25-
git add dist/
26-
git commit -m "chore: Update dist" || echo "No changes to commit"
27-
git push origin HEAD:master
14+
- name: Init a git repo
15+
uses: actions/checkout@v2
16+
- name: Checkout PR
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
run: gh pr checkout ${{ github.event.pull_request.number }}
20+
- name: Package
21+
run: |
22+
npm ci
23+
npm test
24+
npm run package
25+
- name: Commit to PR
26+
if: github.actor == 'dependabot[bot]'
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
run: |
30+
git config --global user.name "GitHub Actions"
31+
git add dist/
32+
git commit -m "chore: Update dist" || echo "No changes to commit"
33+
git push
34+
- name: Check git diff
35+
if: github.actor != 'dependabot[bot]'
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
run: |
39+
git diff --exit-code dist/index.js

0 commit comments

Comments
 (0)