Skip to content

Fix release workflow: sync main to gh-pages and deploy from gh-pages branch#778

Merged
hemarina merged 7 commits intomainfrom
copilot/fix-release-yaml-bug
Mar 19, 2026
Merged

Fix release workflow: sync main to gh-pages and deploy from gh-pages branch#778
hemarina merged 7 commits intomainfrom
copilot/fix-release-yaml-bug

Conversation

Copy link
Contributor

Copilot AI commented Mar 19, 2026

The release.yml workflow was failing because actions/deploy-pages requires the triggering branch (main) to be explicitly allowed in the github-pages environment protection rules.

Changes

  • Updated actions/upload-pages-artifact from v3 to v4 in release.yml, keeping the existing actions/deploy-pages@v4 deployment approach
  • Added new sync-gh-pages.yml reusable workflow that syncs the main branch to gh-pages by force-pushing (supports both workflow_dispatch for standalone use and workflow_call for reuse)
  • Integrated sync-gh-pages.yml as the first job in release.yml — the deploy job depends on it (needs: sync), so running the release workflow automatically syncs main→gh-pages before building and deploying
  • Updated permissions to contents: write (needed for the sync push) and deploy job now checks out the gh-pages branch to use the freshly synced code

Deployment Flow

  1. Trigger "Release Awesome Azd" workflow from the gh-pages branch in the Actions UI
  2. The sync job automatically pushes the latest main content to gh-pages
  3. The deploy job builds from the freshly synced gh-pages branch and deploys via actions/deploy-pages@v4 — since gh-pages is the trigger branch, the github-pages environment protection rules are satisfied
Original prompt

This section details on the original issue you should resolve

<issue_title>Fix release yaml file bug</issue_title>
<issue_description>Fix release yaml: Branch "main" is not allowed to deploy to github-pages due to environment protection rules. Sync changes from main branch to gh-pages branch and use gh-pages branch for release</issue_description>

Comments on the Issue (you are @copilot in this section)


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Co-authored-by: hemarina <104857065+hemarina@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix release yaml file bug by syncing main to gh-pages Fix release workflow: deploy via gh-pages branch instead of Pages deployment API Mar 19, 2026
Copilot AI requested a review from hemarina March 19, 2026 17:57
@hemarina
Copy link
Contributor

@copilot Keep using actions/upload-pages-artifact@v4 + actions/deploy-pages@v4. Add a workflow to sync current main branch to gh-pages branch and use gh-pages branch as trigger branch for actions/deploy-pages.

…es workflow

Co-authored-by: hemarina <104857065+hemarina@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 19, 2026

@copilot Keep using actions/upload-pages-artifact@v4 + actions/deploy-pages@v4. Add a workflow to sync current main branch to gh-pages branch and use gh-pages branch as trigger branch ...

Done in 7d9868b. Reverted release.yml to use actions/upload-pages-artifact@v4 + actions/deploy-pages@v4 (also bumped upload-pages-artifact from v3 to v4). Added a new sync-gh-pages.yml workflow that force-pushes main to gh-pages.

Deployment flow:

  1. Run "Sync Main to GH-Pages" workflow (from main)
  2. Run "Release Awesome Azd" workflow (selecting gh-pages branch in the Actions UI)

Since gh-pages is the trigger branch, the github-pages environment protection rules are satisfied.

Copilot AI changed the title Fix release workflow: deploy via gh-pages branch instead of Pages deployment API Fix release workflow: sync main to gh-pages and deploy from gh-pages branch Mar 19, 2026
@hemarina
Copy link
Contributor

@copilot When I run release yaml, it runs sync-gh-pages.yml first and then the rest of yaml file.

Co-authored-by: hemarina <104857065+hemarina@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 19, 2026

@copilot When I run release yaml, it runs sync-gh-pages.yml first and then the rest of yaml file.

Done in 2cf9874. The release workflow now calls sync-gh-pages.yml as its first job (via workflow_call), then the deploy job runs after it completes (needs: sync). The deploy job checks out the freshly synced gh-pages branch.

The sync-gh-pages.yml workflow also remains independently runnable via workflow_dispatch.

To deploy: trigger "Release Awesome Azd" from the gh-pages branch in the Actions UI — the sync job ensures gh-pages is up to date with main before deploying.

@hemarina hemarina marked this pull request as ready for review March 19, 2026 19:10
Copilot AI review requested due to automatic review settings March 19, 2026 19:10
@hemarina hemarina enabled auto-merge (squash) March 19, 2026 19:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the GitHub Pages release workflow by ensuring the deployment is triggered from an allowed branch (gh-pages) while still deploying the latest main content.

Changes:

  • Adds a reusable workflow to force-sync maingh-pages.
  • Makes the release workflow run the sync job first and deploy from gh-pages.
  • Updates actions/upload-pages-artifact from v3 to v4 and adjusts permissions for pushing.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
.github/workflows/sync-gh-pages.yml Introduces a reusable workflow to sync main to gh-pages via force-push.
.github/workflows/release.yml Runs the sync workflow before deploy, checks out gh-pages for the build, and bumps the upload artifact action to v4.

hemarina and others added 3 commits March 19, 2026 13:24
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@hemarina hemarina merged commit 550755b into main Mar 19, 2026
2 checks passed
@hemarina hemarina deleted the copilot/fix-release-yaml-bug branch March 19, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix release yaml file bug

4 participants