Skip to content

Commit 2376e8f

Browse files
committed
Merge branch 'luojh-add-library-in-dev' of github.com:ustclug/Linux201-docs into luojh-add-library-in-dev
2 parents 43b4eaf + 789c179 commit 2376e8f

File tree

1 file changed

+36
-20
lines changed

1 file changed

+36
-20
lines changed

.github/workflows/build.yaml

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
11
name: build
22

33
on:
4-
push:
5-
branches:
6-
- "*"
7-
pull_request:
8-
branches:
9-
- "*"
10-
11-
permissions:
12-
contents: write
13-
pages: write
14-
id-token: write
4+
- pull_request
5+
- push
156

167
jobs:
178
build:
18-
environment:
19-
name: github-pages
20-
url: ${{ steps.deployment.outputs.page_url }}
219
runs-on: ubuntu-latest
10+
outputs:
11+
commit-info: ${{ steps.commit-info.outputs.COMMIT_INFO }}
2212
steps:
2313
- uses: actions/checkout@v4
2414
with:
@@ -56,6 +46,7 @@ jobs:
5646
globs: |
5747
docs/**/*.md
5848
README.md
49+
5950
- name: Stop and report errors
6051
run: |
6152
git add -A
@@ -69,28 +60,53 @@ jobs:
6960
mkdocs -v build
7061
: > site/.nojekyll
7162
echo -n '201.ustclug.org' > site/CNAME
63+
7264
- name: Upload artifact
73-
if: github.ref == 'refs/heads/master'
7465
uses: actions/upload-pages-artifact@v3
7566
with:
7667
path: site
68+
69+
- name: Generate commit info
70+
id: commit-info
71+
run: |
72+
git log -1 --pretty="COMMIT_INFO=%an: [%h] %s" >> "$GITHUB_OUTPUT"
73+
74+
deploy:
75+
needs: build
76+
if: github.ref == 'refs/heads/master'
77+
environment:
78+
name: github-pages
79+
url: ${{ steps.deployment.outputs.page_url }}
80+
permissions:
81+
contents: write
82+
pages: write
83+
id-token: write
84+
runs-on: ubuntu-latest
85+
steps:
7786
- name: Deploy to GitHub Pages
78-
if: github.ref == 'refs/heads/master'
7987
id: deployment
8088
uses: actions/deploy-pages@v4
8189

90+
- name: Download artifact
91+
uses: actions/download-artifact@v5
92+
with:
93+
name: github-pages
94+
path: site/
95+
8296
- name: Push site to gh-pages branch
83-
if: github.ref == 'refs/heads/master'
8497
run: |
85-
CINFO="$(git log -1 --pretty="%an: [%h] %s")"
8698
git clone --depth=1 --branch=gh-pages --single-branch --no-checkout \
87-
"https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" test
99+
"https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}.git" test
88100
mv test/.git site/.git && rmdir test/
89101
pushd site/ &>/dev/null
102+
if [ -f artifact.tar ]; then
103+
tar xf artifact.tar
104+
rm artifact.tar
105+
fi
90106
git add -A
91107
git -c user.name=GitHub -c [email protected] commit \
92108
-m "Auto deploy from GitHub Actions build ${GITHUB_RUN_NUMBER}" \
93-
-m "$CINFO" \
109+
-m "${{ needs.build.outputs.commit-info }}" \
94110
--allow-empty
95111
git push
96112
popd &>/dev/null

0 commit comments

Comments
 (0)