Skip to content

Commit

Permalink
Replace template URLs within precommit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
kdeldycke committed Mar 18, 2024
1 parent 1e4e587 commit 74f4616
Showing 1 changed file with 8 additions and 28 deletions.
36 changes: 8 additions & 28 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,13 @@ jobs:
with:
github_token: ${{ secrets.WORKFLOW_UPDATE_GITHUB_PAT || secrets.GITHUB_TOKEN }}
source_repo_path: kdeldycke/awesome-template
is_allow_hooks: true
# Replace "/kdeldycke/awesome-template/" in URLs by "/kdeldycke/awesome-<repo_id>/".
hooks: >
precommit:
commands:
- find ./.github/ -type f -iregex ".*\.\(md\|yaml\)$" -print -exec sed -i
"s/\/kdeldycke\/awesome-template\//\/kdeldycke\/${{ github.event.repository.name }}\//g" "{}" \;
pr_title: "[sync] Updates from `awesome-template`"
pr_commit_msg: "[sync] Updates from awesome-template"
pr_branch_name_prefix: "sync-awesome-template"
Expand All @@ -392,31 +399,4 @@ jobs:
</details>
pr_labels: "📚 documentation"
- name: Checkout new template sync branch
uses: actions/checkout@v4.1.2
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: 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: Setup Git user
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
- name: Merge change to previous commit
# XXX Note that this step fails on first run, as reported by:
# https://github.com/AndreasAugustin/actions-template-sync/issues/467#issuecomment-1976345287
run: |
git commit --all --amend --no-edit
- name: Push new commit to PR
run: |
git push --force
pr_labels: "📚 documentation"

0 comments on commit 74f4616

Please sign in to comment.