Setting up automatic build to automatically publish Draft with Sphinx + ablog#
When running a blog with Sphinx + ablog, you can prepare draft articles by setting the post date to a future date. However, it will not be reflected on the website unless the build is run after the release date. This article looks at how to run automated builds.
Background and issues#
ablog sets the article date as .. post:: YYYY-MM-DD, but if the date is in the future, the article will be ignored as a draft.
For example, as of 2025-05-05, even if you write an article like the following:
.. post:: 2025-06-01
:tags: future
:category: ブログ運用
公開は6月1日を予定しています。
This article will actually be output when Sphinx is rebuilt after June 1st.
This site is published on Netlify, but because Netlify uses a push to GitHub as a build trigger, it does not support “automatic publication of future articles.”
Therefore, it is necessary to separately consider a mechanism to automatically rebuild after a future date.
Environment of this site#
This site is operated in the following environment. Please refer to this if you are in a similar environment.
Built with Sphinx + ablog
Source code management with GitHub
Hosted with Netlify
Solution: GitHub Actions × Netlify Build Hook#
Netlify provides a Build Hook feature that allows you to run a build at any time by sending a POST request to a specific URL.
If you access this Build Hook at a fixed time every day using the periodic execution (cron) function of GitHub Actions, a build will occur automatically.
With this, ablog articles past the future date will be checked every day and automatically published.
Setting procedure#
Create a Build Hook with Netlify
Access the Netlify admin screen
Target site → “Site configrations” → “Build & deploy” → “Build hooks”
Add build hook - Hook name: Any (e.g. Daily Scheduled Deploy) - Branch: main (or branch in use)
Make a note of the URL that will be displayed after creation (e.g. https://api.netlify.com/build_hooks/xxxxxxxxxxxxxx)
Register Build Hook in GitHub Secrets (security compatible)
If the Build Hook URL is known, anyone can trigger the build, so we safely manage it with GitHub Secrets.
GitHub repository → Settings → Secrets and variables → Actions
“New repository secret” - Name: NETLIFY_BUILD_HOOK - Value: Build Hook URL obtained with Netlify
Create a GitHub Actions workflow
Create a file like the following in the .github/workflows/ folder of your repository:
.github/workflows/netlify-scheduled-deploy.yml#1name: Netlify Scheduled Deploy 2 3on: 4 schedule: 5 - cron: '0 15 * * *' # JST 0:00(= UTC 15:00) 6 workflow_dispatch: # 手動実行も可能 7 8jobs: 9 trigger-netlify: 10 runs-on: ubuntu-latest 11 steps: 12 - name: Trigger Netlify Build via Secret 13 run: | 14 curl -X POST -d '{}' "${{ secrets.NETLIFY_BUILD_HOOK }}"
🔹 You can also run builds manually from GitHub if needed by adding workflow_dispatch.
Commit and reflect on GitHub
If you commit and push the .yml you created, Netlify build will be performed automatically every day.
Security considerations#
Build Hook URL is treated like a token and should never be made public
If you manage it with a .env file, include it in .gitignore so that it is not included in the repository.
If you use GitHub Secrets, you can rest assured that log output etc. will be automatically masked.
supplement#
cron is based on UTC, so if you want to run it regularly in Japan Time (JST), you need to subtract 9 hours.
If you want to run it every day at 0:00 JST → cron: ‘0 15 * * *’
It is also possible to change to weekly/monthly (e.g. every Monday at 0:00 JST → ‘0 15 * * 1’)
summary#
If you manage a future article as a scheduled post on ablog, it will not be published unless it is hosted on Netlify because it will not be built unless you git push it. This time, by combining Netlify’s Build Hook and GitHub Actions’ cron execution, we were able to trigger builds periodically and automatically publish articles.
This stack is a combination of GitHub Actions + Netlify, and the good thing about it is that it doesn’t cost anything.
Article information
- Post date:
2025-05-05
- author:
Mr. Takagi