Skip to content

Commit b5b6204

Browse files
committed
[ci] Hopefully cured bitrot now
The issue turned out to be to do with modifying external actions: it is only possible to specify `defaults.run.working-directory` for jobs, but **not** for actions which are pulled in with `using`. I've fixed this (temporarily?) by just copying the jobs from the Pelican CI. Hopefully opening a PR against that should allow us to just use their CI action.
1 parent 3cdf39a commit b5b6204

File tree

1 file changed

+93
-60
lines changed

1 file changed

+93
-60
lines changed

.github/workflows/pelican.yml

Lines changed: 93 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
## Pages.
33
## The contents of this file were based on the existing deployment templates in
44
## https://github.com/actions/starter-workflows/tree/main/pages
5-
## as well as the official Pelican docs at
5+
## as well as the official Pelican GH Pages action at
66
## https://github.com/getpelican/pelican/blob/main/.github/workflows/github_pages.yml
77

88
name: Deploy Pelican site to GH Pages
@@ -13,75 +13,108 @@ on:
1313

1414
workflow_dispatch:
1515

16+
17+
### This will be really convenient if/when actions supports changing working dir
18+
###jobs:
19+
### deploy:
20+
### uses: "getpelican/pelican/.github/workflows/github_pages.yml@main"
21+
### # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
22+
### permissions:
23+
### contents: read
24+
### pages: write
25+
### id-token: write
26+
### with:
27+
### settings: "publishconf.py"
28+
### python: "3.9"
29+
### # TODO: update when officially switching to community-managed page
30+
### siteurl: "https://test.idris-lang.org/"
31+
### requirements: "-r requirements.txt"
32+
### # FIXME: remove when workflow is no longer bitrotted
33+
### deploy: false
34+
35+
### For now, we will just copy the Pelican CI and cd "manually"
36+
1637
# c.f. https://docs.github.com/en/actions/how-tos/writing-workflows/choosing-what-your-workflow-does/setting-a-default-shell-and-working-directory
1738
defaults:
1839
run:
1940
shell: bash
2041
working-directory: ./src
2142

22-
jobs:
23-
deploy:
24-
uses: "getpelican/pelican/.github/workflows/github_pages.yml@main"
25-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
26-
permissions:
27-
contents: read
28-
pages: write
29-
id-token: write
30-
with:
31-
settings: "./src/publishconf.py"
32-
python: "3.9"
33-
# TODO: update when officially switching to community-managed page
34-
siteurl: "https://test.idris-lang.org/"
35-
requirements: "-r ./src/requirements.txt"
36-
# FIXME: remove when workflow is no longer bitrotted
37-
deploy: false
38-
43+
env:
44+
SETTINGS: "publishconf.py"
45+
PYTHON: "3.9"
46+
# TODO: update when officially switching to community-managed page
47+
SITEURL: "https://test.idris-lang.org/"
48+
REQUIREMENTS: "-r requirements.txt"
49+
# FIXME: remove when workflow is no longer bitrotted
50+
DEPLOY: false
3951

4052
# Allow one concurrent deployment
4153
concurrency:
4254
group: "pages"
4355
cancel-in-progress: true
4456

45-
### defaults:
46-
### run:
47-
### shell: bash
48-
###
49-
### jobs:
50-
### build:
51-
### runs-on: ubuntu-latest
52-
###
53-
### steps:
54-
### - name: Checkout source
55-
### uses: actions/checkout@v3
56-
###
57-
### - name: Setup Python
58-
### uses: actions/setup-python@v4
59-
### with:
60-
### python-version: "3.9"
61-
### cache: 'pip'
62-
###
63-
### - name: Install Pelican
64-
### run: pip install pelican markdown
65-
###
66-
### - name: Build site using Pelican
67-
### run: |
68-
### cd src
69-
### pelican content -s publishconf.py
70-
### cd ..
71-
###
72-
### - name: Upload site
73-
### uses: actions/upload-pages-artifact@v1
74-
### with:
75-
### path: ./src/output
76-
###
77-
### deploy:
78-
### environment:
79-
### name: github-pages
80-
### url: ${{ steps.deployment.outputs.page_url }}
81-
### runs-on: ubuntu-latest
82-
### needs: build
83-
### steps:
84-
### - name: Deploy to GH Pages
85-
### id: deployment
86-
### uses: actions/deploy-pages@v1
57+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
58+
permissions:
59+
contents: read
60+
pages: write
61+
id-token: write
62+
63+
jobs:
64+
build:
65+
runs-on: ubuntu-latest
66+
steps:
67+
- name: Checkout
68+
uses: actions/checkout@v4
69+
- name: Set up Python
70+
uses: actions/setup-python@v5
71+
with:
72+
python-version: ${{ env.PYTHON }}
73+
- name: Checkout theme
74+
if: ${{ env.THEME }}
75+
run: git clone '${{ env.THEME }}' .theme
76+
- name: Configure GitHub Pages
77+
id: pages
78+
uses: actions/configure-pages@v5
79+
- name: Install requirements
80+
run: pip install ${{ env.REQUIREMENTS }}
81+
- name: Build Pelican site
82+
shell: python
83+
run: |
84+
import subprocess
85+
86+
cmd = "pelican"
87+
cmd += " --settings ${{ env.SETTINGS }}"
88+
cmd += " --extra-settings"
89+
cmd += """ SITEURL='"${{ env.SITEURL || steps.pages.outputs.base_url }}"'"""
90+
cmd += """ FEED_DOMAIN='"${{ env.FEED_DOMAIN || steps.pages.outputs.base_url }}"'"""
91+
cmd += " --output ${{ env.OUTPUT_PATH }}"
92+
93+
if "${{ env.THEME }}":
94+
cmd += " --theme-path .theme"
95+
96+
subprocess.run(cmd, shell=True, check=True)
97+
- name: Fix permissions
98+
run: |
99+
chmod -c -R +rX "${{ env.OUTPUT_PATH }}" | while read line; do
100+
echo "::warning title=Invalid file permissions automatically fixed::$line"
101+
done
102+
- name: Upload artifact
103+
uses: actions/upload-pages-artifact@v3
104+
with:
105+
path: ${{ env.OUTPUT_PATH || "output/" }}
106+
deploy:
107+
concurrency:
108+
group: "pages"
109+
cancel-in-progress: false
110+
if: ${{ env.DEPLOY }}
111+
environment:
112+
name: github-pages
113+
url: ${{ steps.deployment.outputs.page_url }}
114+
runs-on: ubuntu-latest
115+
needs: build
116+
steps:
117+
- name: Deploy to GitHub Pages
118+
id: deployment
119+
uses: actions/deploy-pages@v4
87120

0 commit comments

Comments
 (0)