|
| 1 | +name: Update Repository |
| 2 | + |
| 3 | +on: |
| 4 | + # every Sunday at 00:36 UTC |
| 5 | + # https://crontab.guru/#36_2_*_*_0 |
| 6 | + schedule: |
| 7 | + - cron: 36 2 * * 0 |
| 8 | + |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | + issue_comment: |
| 12 | + types: |
| 13 | + - created |
| 14 | + |
| 15 | +jobs: |
| 16 | + update: |
| 17 | + if: >- |
| 18 | + !github.event.repository.fork |
| 19 | + && ( |
| 20 | + github.event_name == 'schedule' |
| 21 | + || github.event_name == 'workflow_dispatch' |
| 22 | + || ( |
| 23 | + github.event_name == 'issue_comment' |
| 24 | + && github.event.issue.pull_request |
| 25 | + && ( |
| 26 | + github.event.comment.body == '@conda-bot render' |
| 27 | + || github.event.comment.body == '@conda-bot recreate' |
| 28 | + ) |
| 29 | + ) |
| 30 | + ) |
| 31 | + runs-on: ubuntu-latest |
| 32 | + steps: |
| 33 | + - if: github.event_name == 'issue_comment' |
| 34 | + uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 |
| 35 | + with: |
| 36 | + comment-id: ${{ github.event.comment.id }} |
| 37 | + reactions: eyes |
| 38 | + reactions-edit-mode: replace |
| 39 | + token: ${{ secrets.SYNC_TOKEN }} |
| 40 | + |
| 41 | + - if: github.event.comment.body == '@conda-bot render' |
| 42 | + name: Configure git origin |
| 43 | + run: | |
| 44 | + echo REPOSITORY=$(curl --silent ${{ github.event.issue.pull_request.url }} | jq --raw-output '.head.repo.full_name') >> $GITHUB_ENV |
| 45 | + echo REF=$(curl --silent ${{ github.event.issue.pull_request.url }} | jq --raw-output '.head.ref') >> $GITHUB_ENV |
| 46 | +
|
| 47 | + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
| 48 | + with: |
| 49 | + repository: ${{ env.REPOSITORY || github.repository }} |
| 50 | + ref: ${{ env.REF || '' }} |
| 51 | + token: ${{ secrets.SYNC_TOKEN }} |
| 52 | + |
| 53 | + - name: Configure git user |
| 54 | + run: | |
| 55 | + git config --global user.name 'Conda Bot' |
| 56 | + git config --global user.email '18747875+conda-bot@users.noreply.github.com' |
| 57 | +
|
| 58 | + - uses: conda/actions/combine-durations@15f883f14f4232f83658e3609c3316d58905138f # v24.8.0 |
| 59 | + id: durations |
| 60 | + continue-on-error: true |
| 61 | + |
| 62 | + - uses: conda/actions/template-files@15f883f14f4232f83658e3609c3316d58905138f # v24.8.0 |
| 63 | + id: templates |
| 64 | + continue-on-error: true |
| 65 | + |
| 66 | + - name: Commit changes |
| 67 | + # no-op if there are no updates |
| 68 | + continue-on-error: true |
| 69 | + run: | |
| 70 | + git add . |
| 71 | + git commit --message "🤖 updated file(s)" |
| 72 | +
|
| 73 | + - if: github.event.comment.body != '@conda-bot render' |
| 74 | + name: Create fork |
| 75 | + # no-op if the repository is already forked |
| 76 | + run: echo FORK=$(gh repo fork --clone=false --default-branch-only 2>&1 | awk '{print $1}') >> $GITHUB_ENV |
| 77 | + env: |
| 78 | + GH_TOKEN: ${{ secrets.SYNC_TOKEN }} |
| 79 | + |
| 80 | + - if: github.event.comment.body != '@conda-bot render' |
| 81 | + id: create |
| 82 | + # no-op if no commits were made |
| 83 | + uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5 |
| 84 | + with: |
| 85 | + push-to-fork: ${{ env.FORK }} |
| 86 | + token: ${{ secrets.SYNC_TOKEN }} |
| 87 | + branch: update |
| 88 | + delete-branch: true |
| 89 | + title: 🤖 Update infrastructure file(s) |
| 90 | + body: | |
| 91 | + [update.yml]: ${{ github.server_url }}/${{ github.repository }}/blob/main/.github/workflows/update.yml |
| 92 | +
|
| 93 | + Your friendly repository updater. |
| 94 | +
|
| 95 | + ${{ steps.durations.outputs.summary }} |
| 96 | +
|
| 97 | + ${{ steps.templates.outputs.summary }} |
| 98 | +
|
| 99 | + This PR was triggered by @${{ github.triggering_actor }} via ${{ github.event_name }}. |
| 100 | +
|
| 101 | + <details> |
| 102 | + <summary>Commands</summary> |
| 103 | +
|
| 104 | + Trigger actions by commenting on this PR: |
| 105 | +
|
| 106 | + - `@conda-bot render` will run rendering workflows and commit and push any changes to this PR |
| 107 | + - `@conda-bot recreate` will recreate this PR, overwriting any edits that have been made to it |
| 108 | +
|
| 109 | + </details> |
| 110 | +
|
| 111 | + ###### Auto-generated by the [`update.yml`][update.yml] workflow, see ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}. |
| 112 | +
|
| 113 | + - if: github.event.comment.body == '@conda-bot render' |
| 114 | + id: update |
| 115 | + name: Push changes |
| 116 | + run: git push --force-with-lease |
| 117 | + |
| 118 | + - if: always() && github.event_name == 'issue_comment' |
| 119 | + uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 |
| 120 | + with: |
| 121 | + comment-id: ${{ github.event.comment.id }} |
| 122 | + reactions: ${{ (steps.create.conclusion == 'success' || steps.update.conclusion == 'success') && 'hooray' || 'confused' }} |
| 123 | + reactions-edit-mode: replace |
| 124 | + token: ${{ secrets.SYNC_TOKEN }} |
0 commit comments