Sync with upstream template #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sync with upstream template | |
on: | |
schedule: | |
- cron: "0 0 * * 6" # Weekly on Saturday | |
workflow_dispatch: | |
env: | |
UPSTREAM_BRANCH: main | |
UPSTREAM_REPO: caffeine-addictt/template | |
# Setup | |
# 1. Ensure you have a PAT with "contents:write", "workflows:write" and "metadata:read" permissions | |
# https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token | |
# | |
# 2. Write the PAT to the "PERSONAL_ACCESS_TOKEN" secret | |
# https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository | |
# | |
# 3. Ensure that GHactions can write Pull Requests (PRs) to the repository | |
# Repository Settings -> Actions -> General -> Workflow permissions | |
# Check "Allow GitHub Actions to create and approve pull requests" | |
jobs: | |
repo-sync: | |
runs-on: ubuntu-latest | |
# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
if: github.repository != env.UPSTREAM_REPO | |
# https://github.com/actions/checkout#usage | |
with: | |
# uncomment if you use submodules within the source repository | |
# submodules: true | |
token: ${{ secrets.GITHUB_TOKEN || secrets.PERSONAL_ACCESS_TOKEN }} | |
- name: actions-template-sync | |
uses: AndreasAugustin/actions-template-sync@v2 | |
if: github.repository != env.UPSTREAM_REPO | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN || secrets.PERSONAL_ACCESS_TOKEN }} | |
source_repo_path: ${{ env.UPSTREAM_REPO }} | |
upstream_branch: ${{ env.UPSTREAM_BRANCH }} | |
pr_title: "[CI] Sync with upstream template" | |
pr_body: "Merging https://github.com/${SOURCE_REPO_PATH}/commit/${TEMPLATE_GIT_HASH}.This PR was automatically generated by the CI workflow." | |
pr_labels: "CI: Template Sync,Skip-Changelog" |