-
Notifications
You must be signed in to change notification settings - Fork 14
132 lines (113 loc) · 5.23 KB
/
init.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Initiate Repository
on:
workflow_dispatch:
inputs:
org:
description: The GitHub organization within which the repository is located.
required: true
type: choice
options:
- conda
- conda-incubator
default: conda
repo:
description: The repository to push the update workflow to.
required: true
jobs:
push:
if: >-
!github.event.repository.fork
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
# repository: ${{ github.repository }}
path: upstream
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
repository: ${{ github.event.inputs.org }}/${{ github.event.inputs.repo }}
path: downstream
- name: Configure git user
run: |
git config --global user.name 'Conda Bot'
git config --global user.email '18747875+conda-bot@users.noreply.github.com'
- name: (upstream) Remove repository from sync.yml
# no-op if the repository is not in the sync.yml file
continue-on-error: true
run: sed -i '\%${{ github.event.inputs.org }}/${{ github.event.inputs.repo }}$%d' upstream/sync/config.yml
- name: (upstream) Commit changes
# no-op if there are no updates
continue-on-error: true
run: |
cd upstream
git add .
git commit --message "🤖 updated file(s)"
- name: (upstream) Create fork
# no-op if the repository is already forked
run: |
cd upstream
echo ::group::Fork debugging
gh repo fork --clone=false --default-branch-only
echo ::endgroup::
echo UPSTREAM=$(gh repo fork --clone=false --default-branch-only 2>&1 | awk '{print $1}') >> $GITHUB_ENV
env:
GH_TOKEN: ${{ secrets.SYNC_TOKEN }}
- name: (upstream) Create PR
# no-op if no commits were made
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0
with:
path: upstream
push-to-fork: ${{ env.UPSTREAM }}
token: ${{ secrets.SYNC_TOKEN }}
branch: init-${{ github.event.inputs.org }}-${{ github.event.inputs.repo }}
delete-branch: true
title: 🤖 Remove ${{ github.event.inputs.org }}/${{ github.event.inputs.repo }} from `sync.yml`
body: |
[init.yml]: ${{ github.server_url }}/${{ github.repository }}/blob/main/.github/workflows/init.yml
Removes ${{ github.event.inputs.org }}/${{ github.event.inputs.repo }} from the `sync.yml` workflow.
This PR was triggered by @${{ github.triggering_actor }} via ${{ github.event_name }}.
###### Auto-generated by the [`init.yml`][init.yml] workflow, see ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}.
- name: (downstream) Copy (overwrite) update.yml
# no-op if the latest file already exists in the downstream repository
continue-on-error: true
run: |
mkdir -p downstream/.github/workflows/
cp -f upstream/.github/workflows/update.yml downstream/.github/workflows/update.yml
- name: (downstream) Copy (do not overwrite) config.yml
# no-op if the file already exists in the downstream repository
continue-on-error: true
run: |
mkdir -p downstream/.github/template-files/
cp -n upstream/templates/config.yml downstream/.github/template-files/config.yml
- name: (downstream) Commit changes
# no-op if there are no updates
continue-on-error: true
run: |
cd downstream
git add .
git commit --message "🤖 updated file(s)"
- name: (downstream) Create fork
# no-op if the repository is already forked
run: |
cd downstream
echo ::group::Fork debugging
gh repo fork --clone=false --default-branch-only
echo ::endgroup::
echo DOWNSTREAM=$(gh repo fork --clone=false --default-branch-only 2>&1 | awk '{print $1}') >> $GITHUB_ENV
env:
GH_TOKEN: ${{ secrets.SYNC_TOKEN }}
- name: (downstream) Create PR
# no-op if no commits were made
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0
with:
path: downstream
push-to-fork: ${{ env.DOWNSTREAM }}
token: ${{ secrets.SYNC_TOKEN }}
branch: init
delete-branch: true
title: 🤖 Init `update.yml` workflow
body: |
[init.yml]: ${{ github.server_url }}/${{ github.repository }}/blob/main/.github/workflows/init.yml
This adds the `update.yml` workflow (and the accompanying `config.yml`) to this repository to enable regular syncing and templating of standard files (e.g., Code of Conduct file, CLA bot workflow, stale bot workflow, etc.).
This PR was triggered by @${{ github.triggering_actor }} via ${{ github.event_name }}.
###### Auto-generated by the [`init.yml`][init.yml] workflow, see ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}.