diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index b5170fb..fcc0793 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -9,5 +9,62 @@ name: Docs jobs: - docs: - uses: kdeldycke/workflows/.github/workflows/docs.yaml@v3.3.4 \ No newline at end of file + #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 + outputs: + pr_branch: ${{ steps.template_sync.outputs.pr_branch }} + steps: + - uses: actions/checkout@v4.1.1 + - name: Sync from template repo + id: template_sync + uses: AndreasAugustin/actions-template-sync@v1.8.0 + with: + # We need custom PAT with workflows permissions so we can update all the boilerplate .github files from + # awesome-template. + github_token: ${{ secrets.WORKFLOW_UPDATE_GITHUB_PAT || secrets.GITHUB_TOKEN }} + source_repo_path: kdeldycke/awesome-template + pr_title: "[sync] Update from `awesome-template` repository" + pr_commit_msg: "[sync] Update from `awesome-template` repository" + 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 }}" + + # We need a new job to be able to re-call the actions/checkout action and fetch the new PR created above by + # actions-template-sync. This is a known limitation: https://github.com/actions/checkout/issues/439 + awesome-template-update: + name: Update awesome template + needs: + - awesome-template-sync + runs-on: ubuntu-22.04 + # XXX We could merge this second workflow to the one above if actions-template-sync support direct setup of hooks. + # This is being discussed at: https://github.com/AndreasAugustin/actions-template-sync/issues/467 + steps: + - name: Print PR branch ID + run: | + echo "PR branch ID: ${{ needs.awesome-template-sync.outputs.pr_branch }}" + - name: Checkout template sync PR + uses: actions/checkout@v4.1.1 + with: + ref: ${{ needs.awesome-template-sync.outputs.pr_branch }} + fetch-depth: 0 + - name: Update repo URLs + # Replace "/kdeldycke/awesome-template/" in URLs by "/kdeldycke/awesome-/". + run: > + find ./.github/ -type f -iregex '.*\.\(md\|yaml\)$' -print -exec sed --quiet -i + "s/\/kdeldycke\/awesome-template\//\/kdeldycke\/${{ github.event.repository.name }}\//gp" "{}" \; + - name: Push to PR + uses: peter-evans/create-pull-request@v6.0.1 + with: + assignees: ${{ github.actor }} + commit-message: "[sync] Update template URLs" + branch: ${{ needs.awesome-template-sync.outputs.pr_branch }} \ No newline at end of file