Skip to content

Simplify

Simplify #110

Workflow file for this run

---
name: Docs
"on":
push:
# Only targets main branch to avoid amplification effects of auto-fixing
# the exact same stuff in multiple non-rebased branches.
branches:
- main
jobs:
#docs:
# uses: kdeldycke/workflows/.github/workflows/docs.yaml@v3.3.4
awesome-template-sync:
name: Sync awesome template
if: >
startsWith(github.event.repository.name, 'awesome-')
&& github.event.repository.name != 'awesome-template'
runs-on: ubuntu-22.04
# We need custom PAT through the whole job so we get workflow permissions to update all the boilerplate .github
# files from awesome-template.
steps:
- name: Initial checkout
uses: actions/checkout@v4.1.1
with:
token: ${{ secrets.WORKFLOW_UPDATE_GITHUB_PAT || secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Sync from template repo
id: template_sync
uses: AndreasAugustin/actions-template-sync@v1.8.1
with:
github_token: ${{ secrets.WORKFLOW_UPDATE_GITHUB_PAT || secrets.GITHUB_TOKEN }}
source_repo_path: kdeldycke/awesome-template
pr_title: "[sync] Updates from `awesome-template`"
pr_commit_msg: "[sync] Updates from awesome-template"
pr_branch_name_prefix: "sync-awesome-template"
pr_labels: "📚 documentation"
- name: Print PR branch ID
run: |
echo "PR branch ID: ${{ steps.template_sync.outputs.pr_branch }}"
- name: Checkout new template sync branch
uses: actions/checkout@v4.1.1
with:
token: ${{ secrets.WORKFLOW_UPDATE_GITHUB_PAT || secrets.GITHUB_TOKEN }}
ref: ${{ steps.template_sync.outputs.pr_branch }}
fetch-depth: 0
# XXX We cannot rely on peter-evans/create-pull-request to manage the push of the new commit to the PR, as it
# ends up with a: "Unexpected error: fatal: could not open '.git/COMMIT_EDITMSG': Permission denied".
# See: https://github.com/AndreasAugustin/actions-template-sync/issues/484
# So we manage the next steps with bare git calls.
- name: List commits
run: |
git log
- name: Update repo URLs
# Replace "/kdeldycke/awesome-template/" in URLs by "/kdeldycke/awesome-<repo_id>/".
run: >
find ./.github/ -type f -iregex ".*\.\(md\|yaml\)$" -print -exec sed -i
"s/\/kdeldycke\/awesome-template\//\/kdeldycke\/${{ github.event.repository.name }}\//g" "{}" \;
- name: Show diff
run: |
git diff
- name: Setup Git user
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
- name: Deactivate LFS
# XXX Was introduced in https://github.com/AndreasAugustin/actions-template-sync/commit/5335a55
run: |
git config lfs.https://github.com/kdeldycke/${{ github.event.repository.name }}.git/info/lfs.locksverify false
- name: Merge change to previous commit
run: |
git commit --all --amend --no-edit
- name: Push new commit to PR
run: |
git push --force