Scheduled Content Publishing With GitHub Actions

Some content has to appear at a particular moment: a product launch page at 09:00 Berlin time, release notes when the release ships, a security advisory when the embargo lifts. Static sites publish by building, so "publish at 09:00" means "merge and deploy at 09:00". Filtering future-dated posts at build time handles the simple case, as in Scheduling Content Publication With Cron-Triggered Builds, but it requires the content to sit on the main branch beforehand — visible in the repository, in preview deploys and to anyone who knows the URL pattern — and it only works for content, not for the navigation changes, redirects and component updates a launch usually includes.

This guide schedules pull request merges instead: a reviewed pull request carries a publish time, and a scheduled workflow merges it when that time arrives, which triggers the normal deploy. It is set up for a product documentation and marketing site whose launches combine pages, navigation and redirects in one change. It belongs to Content Workflows for Documentation Teams.

Prerequisites

  • Branch protection on main requiring review and passing checks.
  • A deploy workflow that runs on pushes to main.
  • A GitHub App or fine-grained token that can merge pull requests (the default GITHUB_TOKEN cannot trigger further workflows, so a merge made with it would not start the deploy).

How It Works

Sequence of a scheduled pull request merge and deploy Four actors, the author, the pull request, the scheduler workflow and the deploy workflow. The author opens a pull request with a publish-at line in its description and gets it reviewed. Every 15 minutes the scheduler lists open pull requests with a publish time in the past. At the first run after 09:00 it merges the approved pull request. The merge triggers the deploy workflow, which builds and deploys. The scheduler then comments the live time on the pull request. A scheduled launch Author Pull request Scheduler Deploy open PR, "publish-at: 2026-10-14 09:00 Europe/Berlin" reviewed and approved every 15 min: due? mergeable? merge → push to main deployed, comment live time
The launch content is never on main until the scheduled time.

Step 1: Mark Pull Requests With a Publish Time

Authors add one line to the pull request description, with an explicit time zone:

publish-at: 2026-10-14 09:00 Europe/Berlin

A label scheduled makes them easy to list. Writing the zone name rather than an offset avoids daylight-saving mistakes; the scheduler converts it to UTC.

Step 2: The Scheduler Workflow

name: scheduled-merge
on:
  schedule: [{ cron: '7,22,37,52 * * * *' }]
  workflow_dispatch:
jobs:
  merge-due:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/create-github-app-token@v1
        id: app
        with: { app-id: '${{ vars.MERGE_APP_ID }}', private-key: '${{ secrets.MERGE_APP_KEY }}' }
      - uses: actions/github-script@v7
        with:
          github-token: ${{ steps.app.outputs.token }}
          script: |
            const prs = await github.paginate(github.rest.pulls.list, { ...context.repo, state: 'open' });
            for (const pr of prs.filter(p => p.labels.some(l => l.name === 'scheduled'))) {
              const m = /publish-at:\s*(\d{4}-\d\d-\d\d \d\d:\d\d)\s+([\w/]+)/.exec(pr.body || '');
              if (!m) continue;
              const due = zonedToUtc(m[1], m[2]);            // small helper using Intl
              if (Date.now() < due) continue;
              const { data: full } = await github.rest.pulls.get({ ...context.repo, pull_number: pr.number });
              if (full.mergeable_state !== 'clean') {
                await github.rest.issues.createComment({ ...context.repo, issue_number: pr.number,
                  body: `Scheduled time passed but this PR is not mergeable (${full.mergeable_state}). Not published.` });
                continue;
              }
              await github.rest.pulls.merge({ ...context.repo, pull_number: pr.number, merge_method: 'squash' });
              core.notice(`Merged #${pr.number}, due ${m[1]} ${m[2]}`);
            }

The cron runs at minutes 7, 22, 37 and 52, avoiding the top of the hour when GitHub's scheduler is busiest. mergeable_state === 'clean' is true only when required reviews and checks have passed, so branch protection is enforced by GitHub, not by the script.

Step 3: Confirm the Deploy

Merging is not publishing. A step in the deploy workflow, when the commit came from a scheduled merge, comments on the original pull request with the time the site went live, or with a failure notice:

      - if: always() && contains(github.event.head_commit.message, '(scheduled)')
        uses: actions/github-script@v7
        with:
          script: |
            const ok = '${{ job.status }}' === 'success';
            // find PR number from the squash commit message "(#123)" and comment

The squash commit message includes (scheduled) because the scheduler sets commit_title. Authors watching for their launch get a notification either way.

Step 4: Rehearse Important Launches

For launches where a failed build at 09:00 would be costly, the pull request's own preview deploy is the rehearsal: it builds the exact merged result (GitHub Actions builds pull requests against a merge commit), and the checks must be green for the scheduler to merge at all. An hour before, the scheduler posts a reminder comment, and if main has moved, the author can update the branch and let checks rerun.

Timeline of a scheduled launch from rehearsal to live Five events. At 08:00 the scheduler posts a reminder and the preview build is green. At 08:52 a run finds the PR not yet due. At 09:07 the first run after the publish time merges the pull request. At 09:09 the deploy finishes building. At 09:10 the scheduler comments that the content is live. A launch morning Reminder Not yet due Merged Built Live 08:00 preview green 08:52 skip 09:07 first run after 09:00 09:09 deploy runs 09:10 comment on PR
Launches went live a median of 9 minutes after the target time over 30 scheduled merges.

Choosing Between Build-Time Dates and Scheduled Merges

The site uses both mechanisms, for different content. Blog posts carry a date in front matter and are filtered at build time by a daily scheduled build; they need no coordination and nobody minds if a post appears at 06:00 or 06:20. Launches use scheduled merges, because they change more than one file and must not be visible early.

Decision tree for choosing between build-time date filtering and scheduled merges The root asks what is being published. A single post or page with no embargo uses a future date filtered at build time and a daily or hourly build. A launch that changes navigation, redirects or components uses a scheduled pull request merge. Embargoed content that must not be readable early uses a scheduled merge from a private fork with password-protected previews. Which scheduling mechanism? What is being published? Post or page, no embargo Build-time date daily scheduled build Launch with nav and redirects Scheduled merge this guide Embargoed advisory Merge from private fork protected previews
Most content needs only the first branch; launches and advisories need the others.

The cost of scheduled merges is a GitHub App and one workflow file; the cost of build-time dates is that future content is public in the repository and in every preview. Teams with a public repository should be especially careful with the second: a future-dated post merged to main of a public repository is readable by anyone the moment it is merged, long before the build publishes it.

Embargoed Content and Previews

Preview deploys of an embargoed pull request are reachable by anyone with the URL. For embargoed security advisories the team uses password-protected previews, as in Password-Protecting Preview Deployments, and keeps such pull requests in a private fork until a few hours before the scheduled time. For ordinary launches, unguessable preview URLs and noindex headers have been enough.

Cancelling or Moving a Launch

Plans change. Removing the scheduled label cancels a scheduled merge; editing the publish-at line moves it. Both are ordinary edits to the pull request, visible in its history, so there is no separate scheduling system to keep in sync. The scheduler's log in the Actions tab records every decision it made for every pull request — skipped as not due, skipped as not mergeable, merged — which answered the one question that came up after a launch: "why did it go live at 09:22 and not 09:07?" (a required check had been re-run at 09:05 and was still running at 09:07).

Measured Impact

Over six months, compared with the previous practice of a person merging by hand at launch time:

MeasureManual mergeScheduled mergeSource
Launches2230PR history
Median delay after target time18 min9 minTimestamps
Launches more than 1 h late30Timestamps
Launches published early by mistake10Incident log
Launches blocked by missing approval—2 (author notified, fixed in 30 min)PR comments
People needed at launch time1 developer0—

Pitfalls & Rollback

  • Merging with GITHUB_TOKEN. The deploy workflow will not trigger; use an app token.
  • Times without zones. Write the zone name; let the script handle daylight saving.
  • Exact-minute expectations. Scheduled workflows run late; allow 15 minutes.
  • Skipping the deploy check. A merge is not a launch until the deploy succeeds.
  • Rollback: reverting the merged pull request through the normal pipeline unpublishes it; for an urgent removal, the host's rollback to the previous deploy is faster.

Conclusion

Scheduling pull request merges with GitHub Actions publishes whole launches — pages, navigation and redirects — at a set time, keeps embargoed content off the main branch until then, and leaves review and checks to branch protection. Over 30 launches it published a median of 9 minutes after the target with nobody at a keyboard, and never early.

FAQ

How is this different from filtering future-dated posts at build time?

Build-time filtering publishes content whose date has passed on the next build, which suits blog posts but requires the content to be merged in advance, visible in the repository and in preview deploys. Scheduled merges keep the change in an unmerged pull request until the scheduled time, so embargoed content is not on the main branch, and the change can include code, navigation and redirects as well as content.

How accurate is the timing of a scheduled GitHub Actions workflow?

Scheduled workflows run on a best-effort basis and are often delayed by several minutes, more at the top of the hour when load is highest. Running the check every 10 or 15 minutes at an off-peak minute, and allowing for the build and deploy time, gives launches within about 15 minutes of the target, which is fine for most content and not for exact-second embargoes.

What happens if the build fails at the scheduled time?

The merge happens but the deploy does not, so the content is not live. The workflow should check that the deploy succeeded and notify the owner of the pull request if it did not. For important launches, merging into a release branch and building a preview an hour before the scheduled time catches failures early.

How do I prevent a scheduled pull request from merging without review?

Rely on branch protection. The scheduler only merges pull requests that GitHub considers mergeable, which with protection rules means required reviews and checks have passed. A pull request missing approval at its scheduled time is skipped and its author notified.

Filed underHow-tosGitHub Actions