Skip to content

Commit d0dc92d

Browse files
authored
test action (#10)
* added GitHub workflow to automatically build the dist folder when merging a pull request
1 parent 774a35a commit d0dc92d

File tree

6 files changed

+12489
-13
lines changed

6 files changed

+12489
-13
lines changed

.github/workflows/build_dist_on_merge.yml

+17-12
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@ name: Build and Commit Dist Files On Merge
22

33
on:
44
pull_request:
5-
types: [closed]
5+
types: [synchronize, opened, reopened]
66

77
jobs:
88
build:
9-
if: github.event.pull_request.merged == true
109
runs-on: ubuntu-latest
1110

1211
steps:
1312
- name: Checkout code
14-
uses: actions/checkout@v3
13+
uses: actions/checkout@v4
14+
with:
15+
ref: ${{ github.head_ref }}
16+
fetch-depth: 2
1517

1618
- name: Set up Node.js
17-
uses: actions/setup-node@v3
19+
uses: actions/setup-node@v4
1820
with:
1921
node-version: '22'
2022

@@ -24,12 +26,15 @@ jobs:
2426
- name: Build project
2527
run: yarn build
2628

27-
- name: Commit and push changes
29+
- name: Get last commit message
30+
id: last-commit
2831
run: |
29-
git config --global user.name "github-actions[bot]"
30-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
31-
git add dist
32-
git commit --amend --no-edit
33-
git push origin HEAD:${{ github.event.pull_request.head.ref }} --force
34-
env:
35-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
echo "message=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
33+
echo "author=$(git log -1 --pretty=\"%an <%ae>\")" >> $GITHUB_OUTPUT
34+
35+
- uses: stefanzweifel/git-auto-commit-action@v5
36+
with:
37+
commit_message: ${{ steps.last-commit.outputs.message }}
38+
commit_options: '--amend --no-edit'
39+
push_options: '--force'
40+
skip_fetch: true

dist/TEST.txt

-1
This file was deleted.

0 commit comments

Comments
 (0)