Skip to content

Commit ee60e75

Browse files
Merge pull request #1458 from ciecierski/github-pages-refactor
Refactor docs workflow to use GitHub Pages Actions
2 parents 7668e6f + da9c997 commit ee60e75

1 file changed

Lines changed: 31 additions & 28 deletions

File tree

.github/workflows/docs.yaml

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ on: # yamllint disable-line rule:truthy
1313
- docs_user/**
1414
- Gemfile
1515
- Makefile
16+
permissions:
17+
contents: read
18+
concurrency:
19+
group: pages
20+
cancel-in-progress: false
1621
jobs:
1722
build:
1823
runs-on: ubuntu-latest
1924
steps:
2025
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
21-
with:
22-
# this fetches all branches. Needed because we need gh-pages branch for deploy to work
23-
fetch-depth: 0
2426
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
2527
with:
2628
python-version: '3.9'
@@ -47,17 +49,17 @@ jobs:
4749
exit 1
4850
fi
4951
50-
- name: Prepare gh-pages branch
52+
- name: Prepare site
5153
run: |
52-
git config user.name github-actions
53-
git config user.email github-actions@github.com
54+
mkdir -p _site
55+
mv -T docs_build/adoption-user _site/user
56+
mv -T docs_build/adoption-dev _site/dev
5457
55-
git branch -D gh-pages &>/dev/null || true
56-
git checkout -b gh-pages aabb4803f89a3b006094d8ae7a933650f644d036
58+
mv _site/user/index-upstream.html _site/user/index.html
59+
mv _site/user/index-downstream.html _site/user/downstream.html
60+
mv _site/dev/index-upstream.html _site/dev/index.html
5761
58-
- name: Create index.html
59-
run: |
60-
cat > index.html <<EOF
62+
cat > _site/index.html <<EOF
6163
<!DOCTYPE html>
6264
<html>
6365
<head>
@@ -115,21 +117,22 @@ jobs:
115117
</html>
116118
EOF
117119
118-
- name: Commit asciidoc docs
119-
run: |
120-
mv -T docs_build/adoption-user user
121-
mv -T docs_build/adoption-dev dev
122-
123-
mv user/index-upstream.html user/index.html
124-
mv user/index-downstream.html user/downstream.html
125-
mv dev/index-upstream.html dev/index.html
126-
127-
git add user
128-
git add dev
129-
git add index.html
130-
git commit -m "Rendered docs"
120+
- name: Upload Pages artifact
121+
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5
122+
with:
123+
path: _site
131124

132-
- name: Push rendered docs to gh-pages
133-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
134-
run: |
135-
git push --force origin gh-pages
125+
deploy:
126+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
127+
needs: build
128+
runs-on: ubuntu-latest
129+
environment:
130+
name: github-pages
131+
url: ${{ steps.deployment.outputs.page_url }}
132+
permissions:
133+
pages: write
134+
id-token: write
135+
steps:
136+
- name: Deploy to GitHub Pages
137+
id: deployment
138+
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5

0 commit comments

Comments
 (0)