Imaging you have a repo with default branch
main and another branch
X. You want to have
X always up-to-date, maybe it is deployed to the staging environment nightly. Here is how to update the branch
X automatically using a GitHub Action.
🎁 This example is available at bahmutov/self-update-branch.
I am using a GH Action workflow to update the branch
X nightly or when manually triggered. See the file update-branch.yml
I need to use the GitHub personal access token in order for the update commit to trigger other CI services.
You can find a pull request #1 that automatically gets the new updates from the
main branch. A merged commit into the branch
X triggers the CI runs. In the screenshot below, the merge commit triggers another GitHub workflow
test-branch-x and a CircleCI workflow.
One use case for keeping a branch evergreen using the approach described in this blog post is deploying an instrumented version of the application for testing to collect the code coverage information. Read the blog post Code Coverage For Nextjs Application.