Skip to content

Commit 15676d0

Browse files
committed
Fail if GitHub Pages is not correctly configured
Previously, the actions/deploy-pages@v4 step would fail with a hard-to-understand error message if the repo is not configured to have GitHub Pages published from Actions. Add a check at the start of the composite action, and fail the whole job if the repo is misconfigured, having emitted a summary explaining the problem. Since Actions workflows are disabled on forks by default, it seems OK to make this a hard failure: if someone has gone to the trouble of enabling Actions on their fork of a project using this action, then they presumably would like to be told why it isn't working.
1 parent e84d047 commit 15676d0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

action.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ inputs:
1010
runs:
1111
using: composite
1212
steps:
13+
- name: Check that GitHub Pages is correctly configured
14+
env:
15+
GH_TOKEN: ${{ github.token }}
16+
shell: bash
17+
run: |
18+
if ! gh api "repos/${{ github.repository }}/pages" | jq --exit-status '.build_type == "workflow"'
19+
then
20+
echo -n "Check that Pages is enabled, with the source set to GitHub Actions, in the " >> "$GITHUB_STEP_SUMMARY"
21+
echo "[repository settings](https://github.com/${{ github.repository }}/settings/pages)." >> "$GITHUB_STEP_SUMMARY"
22+
exit 1
23+
fi
24+
1325
- uses: astral-sh/setup-uv@v6
1426
with:
1527
cache-dependency-glob: |

0 commit comments

Comments
 (0)