Simplifying Retype Deployments with Azure Static Web Apps #722
JoelMTaylor
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Show and Tell: Simplifying Retype Deployments with Azure Static Web Apps
Introduction
Deploying static websites with Retype and Azure Static Web Apps (SWA) can be incredibly streamlined, but the process isn't without its challenges. This post documents the journey of replacing an inefficient two-step GitHub Actions workflow with a single streamlined solution, while tackling branch management, GitHub token limitations, and general workflow design.
Technologies Used
Original Two-Step Workflow
Overview
Initially, the workflow required two separate GitHub Actions inside one
yml
file:wwwroot
folder of themain
branch.wwwroot
folder to Azure Static Web Apps.Problem
The two-step approach required two pushes to update the live site:
wwwroot
folder inmain
.This redundancy was time-consuming and error-prone, prompting a search for a better solution.
Transitioning to a Single-Step Workflow
New Approach
The goal was to directly publish the static content generated by Retype into a
publish
branch (same/equivalent to the defaultretype
branch), separate frommain
, and trigger the Azure deployment from this branch.Using Retype's default example GitHub Action (example here) and the automatically generated Azure SWA action as templates, the following issues arose:
Challenges Encountered
1. Branch Management Confusion
GitHub typically treats branch workflows as duplications, whereas Retype expects the
publish
(retype
) branch to host entirely different static content. Understanding this distinction was key to aligning the workflows. It is worth noting that during this process, the "1 commit behind/ahead" status on the publish branch can generally be ignored without impacting functionality.2. GitHub Token Limitation
By default, GitHub prevents workflows from triggering subsequent workflows if changes are pushed using the default
GITHUB_TOKEN
. As stated in GitHub Community Discussions (also, see this other related discussion here):This limitation required the use of a Personal Access Token (PAT) with appropriate permissions.
Final Solution
Here are the final GitHub Actions workflows that resolved the issues.
retype-build.yml
azure-publish.yml
Key Learnings
Understand Workflow Behavior:
publish
branch logic.PAT Usage is Essential:
GITHUB_TOKEN
cannot trigger subsequent workflows. Using a PAT resolved this issue and enabled seamless integration between Retype and Azure SWA.Efficient Builds Save Time:
Links and Resources
Conclusion
This experience highlighted the importance of understanding GitHub workflows, branch management, and the nuances of authentication tokens. By combining Retype and Azure Static Web Apps with thoughtful GitHub Actions workflows, we achieved a streamlined deployment process.
Feel free to share your own tips or similar experiences in the comments below!
Beta Was this translation helpful? Give feedback.
All reactions