Skip to content

Commit 23ae683

Browse files
conda-botmarcelotrevisanikenodegard
authored
🤖 Init update.yml workflow (#568)
* 🤖 updated file(s) * Update .github/template-files/config.yml Co-authored-by: Ken Odegard <kodegard@anaconda.com> * Update .github/template-files/config.yml Co-authored-by: Ken Odegard <kodegard@anaconda.com> * Update .github/template-files/config.yml Co-authored-by: Ken Odegard <kodegard@anaconda.com> * Update .github/template-files/config.yml Co-authored-by: Ken Odegard <kodegard@anaconda.com> * Update .github/template-files/config.yml Co-authored-by: Ken Odegard <kodegard@anaconda.com> --------- Co-authored-by: Marcelo Duarte Trevisani <marcelotrevisani@users.noreply.github.com> Co-authored-by: Ken Odegard <kodegard@anaconda.com>
1 parent 3402aa0 commit 23ae683

File tree

2 files changed

+174
-0
lines changed

2 files changed

+174
-0
lines changed

.github/template-files/config.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
conda/governance:
2+
# [required] community files
3+
- CODE_OF_CONDUCT.md
4+
5+
conda/infrastructure:
6+
# [required] general workflows
7+
- .github/workflows/cla.yml
8+
- .github/workflows/update.yml
9+
10+
# [optional] to include repo in https://github.com/orgs/conda/projects/2
11+
# - .github/workflows/issues.yml
12+
# - .github/workflows/labels.yml
13+
# - .github/workflows/project.yml
14+
15+
# [optional] stale bot workflows
16+
# - .github/workflows/stale.yml
17+
# - .github/workflows/lock.yml
18+
19+
# [optional] general processes for the conda org
20+
# - src: templates/HOW_WE_USE_GITHUB.md
21+
# dst: HOW_WE_USE_GITHUB.md
22+
23+
# [optional] standard issue templates
24+
# - src: templates/issues/bug.yml
25+
# dst: .github/ISSUE_TEMPLATE/0_bug.yml
26+
27+
# - src: templates/issues/feature.yml
28+
# dst: .github/ISSUE_TEMPLATE/1_feature.yml
29+
30+
# - src: templates/issues/documentation.yml
31+
# dst: .github/ISSUE_TEMPLATE/2_documentation.yml
32+
33+
# - src: templates/issues/epic.yml
34+
# dst: .github/ISSUE_TEMPLATE/epic.yml
35+
36+
# [optional] standard PR template
37+
# - src: templates/pull_requests/news_tests_docs.md
38+
# dst: .github/template-files/templates/pull_request_template_details.md
39+
# - src: templates/pull_requests/base.md
40+
# dst: .github/PULL_REQUEST_TEMPLATE.md
41+
42+
# [optional] rever release files
43+
# - src: templates/releases/RELEASE.md
44+
# dst: RELEASE.md
45+
# with:
46+
# placeholder: YY.M
47+
# - src: templates/releases/rever.xsh
48+
# dst: rever.xsh
49+
# - src: templates/releases/TEMPLATE
50+
# dst: news/TEMPLATE

.github/workflows/update.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
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

Comments
 (0)