Skip to content

Commit 4d17f4e

Browse files
gagoaractions-user
andauthored
This Workflow should provide us with the dist/ bundle always up to date (#247)
The latest commits from @DevJeon1358 have been great for the action to keep working correctly with the latest updates from Github (mainly deprecations). But Something I did not cover before in this action was the ability to keep the built binary within the action (that has to be committed) up to date when a PR changes libraries or code itself. This PR adds a workflow that "Hopefully" will solve this. Co-authored-by: GitHub Action <[email protected]>
1 parent 1136b6b commit 4d17f4e

File tree

2 files changed

+83
-19
lines changed

2 files changed

+83
-19
lines changed

.github/workflows/rebuild_dist.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: rebuild dist/ if needed
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
with:
12+
ref: ${{github.head_ref}}
13+
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
14+
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
15+
16+
- uses: actions/[email protected]
17+
with:
18+
cache: 'npm'
19+
node-version-file: '.nvmrc'
20+
21+
- run: npm install
22+
- name: build dist/
23+
run: npm run build
24+
- run: |
25+
STATUS=$(git diff --quiet && echo clean || echo modified)
26+
echo "status=$(echo $STATUS)" >> $GITHUB_OUTPUT
27+
id: gitStatus
28+
- run: |
29+
echo ${{ steps.gitStatus.outputs.status }}
30+
echo ${{ contains(steps.gitStatus.outputs.status, 'modified') }}
31+
- name: Commit dist/ files
32+
if: contains(steps.gitStatus.outputs.status, 'modified')
33+
run: |
34+
set -x
35+
git config --local user.email "[email protected]"
36+
git config --local user.name "GitHub Action"
37+
git commit -m "rebuild dist/" -a
38+
- id: auth
39+
if: contains(steps.gitStatus.outputs.status, 'modified')
40+
uses: jnwng/github-app-installation-token-action@v2
41+
with:
42+
appId: ${{ secrets.COMMIT_BUILD_TO_PR_APP_ID }}
43+
installationId: ${{ secrets.COMMIT_BUILD_TO_PR_INSTALLATION_ID }}
44+
privateKey: ${{ secrets.COMMIT_BUILD_TO_PR_PRIVATE_KEY }}
45+
- name: Push changes
46+
if: contains(steps.gitStatus.outputs.status, 'modified')
47+
uses: ad-m/github-push-action@master
48+
with:
49+
github_token: ${{ steps.auth.outputs.token }}
50+
branch: ${{github.head_ref}}

dist/index.js

Lines changed: 33 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)