1
1
name : build
2
2
3
3
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
15
6
16
7
jobs :
17
8
build :
18
- environment :
19
- name : github-pages
20
- url : ${{ steps.deployment.outputs.page_url }}
21
9
runs-on : ubuntu-latest
10
+ outputs :
11
+ commit-info : ${{ steps.commit-info.outputs.COMMIT_INFO }}
22
12
steps :
23
13
- uses : actions/checkout@v4
24
14
with :
56
46
globs : |
57
47
docs/**/*.md
58
48
README.md
49
+
59
50
- name : Stop and report errors
60
51
run : |
61
52
git add -A
@@ -69,28 +60,53 @@ jobs:
69
60
mkdocs -v build
70
61
: > site/.nojekyll
71
62
echo -n '201.ustclug.org' > site/CNAME
63
+
72
64
- name : Upload artifact
73
- if : github.ref == 'refs/heads/master'
74
65
uses : actions/upload-pages-artifact@v3
75
66
with :
76
67
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 :
77
86
- name : Deploy to GitHub Pages
78
- if : github.ref == 'refs/heads/master'
79
87
id : deployment
80
88
uses : actions/deploy-pages@v4
81
89
90
+ - name : Download artifact
91
+ uses : actions/download-artifact@v5
92
+ with :
93
+ name : github-pages
94
+ path : site/
95
+
82
96
- name : Push site to gh-pages branch
83
- if : github.ref == 'refs/heads/master'
84
97
run : |
85
- CINFO="$(git log -1 --pretty="%an: [%h] %s")"
86
98
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
88
100
mv test/.git site/.git && rmdir test/
89
101
pushd site/ &>/dev/null
102
+ if [ -f artifact.tar ]; then
103
+ tar xf artifact.tar
104
+ rm artifact.tar
105
+ fi
90
106
git add -A
91
107
git -c user.name=GitHub -c [email protected] commit \
92
108
-m "Auto deploy from GitHub Actions build ${GITHUB_RUN_NUMBER}" \
93
- -m "$CINFO " \
109
+ -m "${{ needs.build.outputs.commit-info }} " \
94
110
--allow-empty
95
111
git push
96
112
popd &>/dev/null
0 commit comments