Update Repository #31
This file contains hidden or 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: Update Repository | |
| # Deny all permissions by default | |
| permissions: {} | |
| on: | |
| # every Sunday at 00:36 UTC | |
| # https://crontab.guru/#36_2_*_*_0 | |
| schedule: | |
| - cron: 36 2 * * 0 | |
| workflow_dispatch: | |
| issue_comment: | |
| types: | |
| - created | |
| jobs: | |
| update: | |
| if: >- | |
| !github.event.repository.fork | |
| && ( | |
| github.event_name == 'schedule' | |
| || github.event_name == 'workflow_dispatch' | |
| || ( | |
| github.event_name == 'issue_comment' | |
| && github.event.issue.pull_request | |
| && ( | |
| github.event.comment.body == '@conda-bot render' | |
| || github.event.comment.body == '@conda-bot recreate' | |
| ) | |
| ) | |
| ) | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # for committing changes | |
| pull-requests: write # for creating pull requests | |
| issues: write # for commenting on issues | |
| steps: | |
| - if: github.event_name == 'issue_comment' | |
| uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0 | |
| with: | |
| comment-id: ${{ github.event.comment.id }} | |
| reactions: eyes | |
| reactions-edit-mode: replace | |
| token: ${{ secrets.SYNC_TOKEN }} | |
| - if: github.event.comment.body == '@conda-bot render' | |
| name: Configure git origin | |
| env: | |
| REPOSITORY: ${{ github.event.issue.pull_request.head.repo.full_name }} | |
| REF: ${{ github.event.issue.pull_request.head.ref }} | |
| run: | | |
| echo "REPOSITORY=${REPOSITORY}" >> $GITHUB_ENV | |
| echo "REF=${REF}" >> $GITHUB_ENV | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| repository: ${{ env.REPOSITORY || github.repository }} | |
| ref: ${{ env.REF || '' }} | |
| token: ${{ secrets.SYNC_TOKEN }} | |
| persist-credentials: false | |
| - name: Configure git user | |
| run: | | |
| git config --global user.name 'Conda Bot' | |
| git config --global user.email '18747875+conda-bot@users.noreply.github.com' | |
| - uses: conda/actions/combine-durations@f05161c6e6e37a49b17c8e0b436197b53830318a # v25.9.2 | |
| id: durations | |
| continue-on-error: true | |
| - uses: conda/actions/template-files@f05161c6e6e37a49b17c8e0b436197b53830318a # v25.9.2 | |
| id: templates | |
| continue-on-error: true | |
| - name: Commit changes | |
| # no-op if there are no updates | |
| continue-on-error: true | |
| run: | | |
| git add . | |
| git commit --message "🤖 updated file(s)" | |
| - if: github.event.comment.body != '@conda-bot render' | |
| name: Create fork | |
| # no-op if the repository is already forked | |
| run: echo FORK=$(gh repo fork --clone=false --default-branch-only 2>&1 | awk '{print $1}') >> $GITHUB_ENV | |
| env: | |
| GH_TOKEN: ${{ secrets.SYNC_TOKEN }} | |
| - if: github.event.comment.body != '@conda-bot render' | |
| id: create | |
| # no-op if no commits were made | |
| uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 | |
| with: | |
| push-to-fork: ${{ env.FORK }} | |
| token: ${{ secrets.SYNC_TOKEN }} | |
| branch: update | |
| delete-branch: true | |
| title: 🤖 Update infrastructure file(s) | |
| body: | | |
| [update.yml]: ${{ github.server_url }}/${{ github.repository }}/blob/main/.github/workflows/update.yml | |
| Your friendly repository updater. | |
| ${{ steps.durations.outputs.summary }} | |
| ${{ steps.templates.outputs.summary }} | |
| This PR was triggered by @${{ github.triggering_actor }} via ${{ github.event_name }}. | |
| <details> | |
| <summary>Commands</summary> | |
| Trigger actions by commenting on this PR: | |
| - `@conda-bot render` will run rendering workflows and commit and push any changes to this PR | |
| - `@conda-bot recreate` will recreate this PR, overwriting any edits that have been made to it | |
| </details> | |
| ###### Auto-generated by the [`update.yml`][update.yml] workflow, see ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}. | |
| - if: github.event.comment.body == '@conda-bot render' | |
| id: update | |
| name: Push changes | |
| run: git push --force-with-lease | |
| - if: always() && github.event_name == 'issue_comment' | |
| uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0 | |
| with: | |
| comment-id: ${{ github.event.comment.id }} | |
| reactions: ${{ (steps.create.conclusion == 'success' || steps.update.conclusion == 'success') && 'hooray' || 'confused' }} | |
| reactions-edit-mode: replace | |
| token: ${{ secrets.SYNC_TOKEN }} |