Skip to content

Commit de544a5

Browse files
committed
.github: deploy docs to project's pages
Signed-off-by: Joachim Wiberg <[email protected]>
1 parent 0d48d1d commit de544a5

File tree

1 file changed

+47
-15
lines changed

1 file changed

+47
-15
lines changed

.github/workflows/docs.yml

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ on:
1919

2020
permissions:
2121
contents: read
22-
pages: write
23-
id-token: write
24-
25-
concurrency:
26-
group: "pages"
27-
cancel-in-progress: false
2822

2923
jobs:
3024
build:
@@ -48,21 +42,59 @@ jobs:
4842
pipx inject mkdocs mkdocs-callouts
4943
5044
- name: Build documentation
51-
run: mkdocs build
45+
run: mkdocs build --clean
5246

53-
- name: Upload Pages artifact
54-
uses: actions/upload-pages-artifact@v3
47+
- name: Upload site artifact
48+
uses: actions/upload-artifact@v4
5549
with:
50+
name: site
5651
path: site/
5752

5853
deploy:
5954
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
6055
needs: build
6156
runs-on: ubuntu-latest
62-
environment:
63-
name: github-pages
64-
url: ${{ steps.deployment.outputs.page_url }}
57+
6558
steps:
66-
- name: Deploy to GitHub Pages
67-
id: deployment
68-
uses: actions/deploy-pages@v4
59+
- name: Download site artifact
60+
uses: actions/download-artifact@v4
61+
with:
62+
name: site
63+
path: site/
64+
65+
- name: Checkout pages repo
66+
uses: actions/checkout@v4
67+
with:
68+
repository: finit-project/finit-project.github.io
69+
path: pages
70+
ssh-key: ${{ secrets.DOCS_DEPLOY_KEY }}
71+
persist-credentials: true
72+
73+
- name: Setup SSH for push
74+
run: |
75+
mkdir -p ~/.ssh
76+
chmod 700 ~/.ssh
77+
ssh-keyscan github.com >> ~/.ssh/known_hosts
78+
79+
- name: Sync site to pages repo
80+
run: |
81+
rsync -a --delete --exclude .git site/ pages/
82+
83+
- name: Commit and push
84+
run: |
85+
cd pages
86+
87+
if [ -z "$(git status --porcelain)" ]; then
88+
exit 0
89+
fi
90+
91+
SRC_REPO="${GITHUB_REPOSITORY}"
92+
SRC_REF="$(git -C .. rev-parse --short HEAD)"
93+
SRC_URL="https://github.com/${SRC_REPO}/commit/${SRC_REF}"
94+
95+
git config user.name "GitHub Actions"
96+
git config user.email "[email protected]"
97+
git add .
98+
git commit -m "docs: update from ${SRC_REPO}@${SRC_REF}" \
99+
-m "For details, see ${SRC_URL}"
100+
git push

0 commit comments

Comments
 (0)