Custom workflow and release publication #145042
Replies: 3 comments
-
Upon further reading, it appears I was missing the environment setting: environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }} I'll know for certain when I do another release in a day or two, but I expect that will solve it. |
Beta Was this translation helpful? Give feedback.
-
It didn't work. To be clear about the conditions:
At this point I'm thoroughly convinced that there's something wrong with the action itself or there's something missing in the documentation. Any help would be appreciated. |
Beta Was this translation helpful? Give feedback.
-
I've narrowed it down to an easily replicable case at https://github.com/KDean-Dolphin/BadPages and attached here. You can see the results at https://kdean-dolphin.github.io/BadPages. These are the files of interest: pages/index.htmlA template for the site. It's a simple table that displays the event that triggered the workflow, the reference (branch or tag), the commit, and the date/time of the build. nonceA simple text file used to trigger a requirement to commit and push to GitHub. You can update the file by changing the numeric value at the bottom manually or by using .github/workflows/build-and-publish.ymlThis is where the magic happens. I've replicated the file below. The build environment is set to The steps are:
If you look at the "Actions" tab of the repository, you will see that two actions have been run. At the bottom is the initial commit, which is a push to "main" event. The one above that is the v1 release publication. That should be the current version of the site. However, if you look at the site, you will see the content from the push event, not from the release event. When I download the github-pages.zip file from the release publication run, the index.html is what I expect it to be (i.e., it shows the release event and tag, not the push event and branch as displayed on the site). name: Build and publish to GitHub Pages
on:
release:
types:
- published
push:
branches:
- main
permissions:
id-token: write
pages: write
jobs:
build:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout default repository
uses: actions/checkout@v4
- name: Patch index.html
run: |
sed -i -e "s/EVENT/${{ github.event_name }}/g" pages/index.html
sed -i -e "s/REF/${{ github.ref_name }}/g" pages/index.html
sed -i -e "s/COMMIT/${{ github.sha }}/g" pages/index.html
sed -i -e "s/DATE_TIME/`date`/g" pages/index.html
- name: Configure GitHub Pages
uses: actions/configure-pages@v5
- name: Upload pages directory
uses: actions/upload-pages-artifact@v3
with:
path: pages
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4 |
Beta Was this translation helpful? Give feedback.
-
Select Topic Area
Question
Body
I have a custom workflow for a fairly complex GitHub Pages deployment. The relevant parts are:
For those that are interested, everything here is in the repository at https://github.com/aidc-toolkit/aidc-toolkit.github.io.
The script works fine when triggered by a push to "main". However, when triggered by a release publication, everything appears to succeed but the GitHub Pages site is never actually published (I confirm this by comparing the contents of the generated artifact with the actual site).
After some digging, I determined that the problem was likely in "Settings / Environments / github-pages", which by default has a "Deployment branches and tags" rule set to allow the "main" branch only to be deployed. I added a wildcard tag rule "v*.." to match my version tag format and the UI confirmed that the rule matches my existing tags.
Despite that, the deployment is still not happening on release publication. The deploy-pages action reports success, but nothing actually happens. Rerunning the build and enabling debug logging doesn't add anything useful.
Any thoughts on why this is? Thanks.
Beta Was this translation helpful? Give feedback.
All reactions