Skip to content

Commit 789c179

Browse files
committed
Merge branch 'master' into luojh-add-library-in-dev
2 parents b091284 + 9ff3d5b commit 789c179

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

.github/workflows/build.yaml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
jobs:
88
build:
99
runs-on: ubuntu-latest
10+
outputs:
11+
commit-info: ${{ steps.commit-info.outputs.COMMIT_INFO }}
1012
steps:
1113
- uses: actions/checkout@v4
1214
with:
@@ -64,29 +66,47 @@ jobs:
6466
with:
6567
path: site
6668

69+
- name: Generate commit info
70+
id: commit-info
71+
run: |
72+
git log -1 --pretty="COMMIT_INFO=%an: [%h] %s" >> "$GITHUB_OUTPUT"
73+
6774
deploy:
6875
needs: build
6976
if: github.ref == 'refs/heads/master'
7077
environment:
7178
name: github-pages
7279
url: ${{ steps.deployment.outputs.page_url }}
80+
permissions:
81+
contents: write
82+
pages: write
83+
id-token: write
7384
runs-on: ubuntu-latest
7485
steps:
7586
- name: Deploy to GitHub Pages
7687
id: deployment
7788
uses: actions/deploy-pages@v4
7889

90+
- name: Download artifact
91+
uses: actions/download-artifact@v5
92+
with:
93+
name: github-pages
94+
path: site/
95+
7996
- name: Push site to gh-pages branch
8097
run: |
81-
CINFO="$(git log -1 --pretty="%an: [%h] %s")"
8298
git clone --depth=1 --branch=gh-pages --single-branch --no-checkout \
83-
"https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" test
99+
"https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}.git" test
84100
mv test/.git site/.git && rmdir test/
85101
pushd site/ &>/dev/null
102+
if [ -f artifact.tar ]; then
103+
tar xf artifact.tar
104+
rm artifact.tar
105+
fi
86106
git add -A
87107
git -c user.name=GitHub -c [email protected] commit \
88108
-m "Auto deploy from GitHub Actions build ${GITHUB_RUN_NUMBER}" \
89-
-m "$CINFO" \
109+
-m "${{ needs.build.outputs.commit-info }}" \
90110
--allow-empty
91111
git push
92112
popd &>/dev/null

0 commit comments

Comments
 (0)