-
Notifications
You must be signed in to change notification settings - Fork 5
149 lines (136 loc) · 5.15 KB
/
create-prepare-pr.yaml
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: create-prepare-pr
on:
workflow_call:
inputs:
distro:
required: true
type: string
workflow_dispatch:
inputs:
distro:
required: true
type: string
jobs:
create-pr:
runs-on: ubuntu-latest
outputs:
sha: ${{ steps.pr.outputs.pull-request-head-sha }}
pr: ${{ steps.pr.outputs.pull-request-number }}
epoch: ${{ steps.vars.outputs.epoch }}
steps:
- uses: actions/checkout@v3
- name: "get distro info"
id: yaml
uses: qiime2/distributions/.github/actions/read-yaml@dev
with:
file: data.yaml
- name: set epoch and date
id: vars
shell: bash
run: |
echo epoch=${{ fromJSON(steps.yaml.outputs.data).active_epoch }} >> $GITHUB_OUTPUT
echo today=$(date +'%Y-%m-%d') >> $GITHUB_OUTPUT
- name: modify file
shell: bash
run: |
echo '# modified: ${{ steps.vars.outputs.today }}' >> '${{ steps.vars.outputs.epoch }}/${{ inputs.distro }}/passed/seed-environment-conda.yml'
- name: Create Pull Request
id: pr
uses: qiime2/create-pull-request@v5
with:
token: ${{ secrets.BOT_PAT }}
branch: Prepare-${{ steps.vars.outputs.epoch }}/${{ inputs.distro }}/${{ steps.vars.outputs.today }}
title: "[${{ inputs.distro }}] Automated Trial (Prepare)"
body: |
Automated updates from `create-prepare-pr.yaml`
triggered by ${{ github.event_name }}.
author: "q2d2 <[email protected]>"
committer: "q2d2 <[email protected]>"
commit-message: |
Automated updates to seed environment: ${{ inputs.distro }}
await-workflow:
needs: [create-pr]
runs-on: ubuntu-latest
outputs:
gh-response: ${{ steps.merge-trial.outputs.gh-response }}
steps:
- name: get workflow id
id: get-id
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
sleep 30 # let the workflow start
echo run-id=$(
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/qiime2/distributions/actions/runs?head_sha=${{ needs.create-pr.outputs.sha }} \
-q '.workflow_runs[] | select(.name == "ci-distro-trial").id' | head -n 1
) >> $GITHUB_OUTPUT
- name: await workflow id ${{ steps.get-id.outputs.run-id }}
uses: Codex-/[email protected]
with:
token: ${{ github.token }}
repo: distributions
owner: qiime2
run_id: ${{ steps.get-id.outputs.run-id }}
run_timeout_seconds: 21600
poll_interval_ms: 45000
- name: merge trial
id: merge-trial
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
GH_RESPONSE=$(
gh api \
--method PUT \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/qiime2/distributions/pulls/${{ needs.create-pr.outputs.pr }}/merge
)
echo "gh-response=$GH_RESPONSE" >> $GITHUB_OUTPUT
update-latest-envs:
needs: [create-pr, await-workflow]
runs-on: ubuntu-latest
outputs:
env-pr: ${{ steps.env-updates-pr.outputs.pull-request-number }}
steps:
- uses: actions/checkout@v3
- name: copy updated env file from merged prepare pr
id: copy-env
if: contains(${{ needs.await-workflow.outputs.gh-response }}, 'merged:true')
run: |
cp '${{ needs.create-pr.outputs.epoch }}/${{ inputs.distro }}/passed/qiime2-${{ inputs.distro }}-macos-latest-conda.yml' './latest/passed/'
cp '${{ needs.create-pr.outputs.epoch }}/${{ inputs.distro }}/passed/qiime2-${{ inputs.distro }}-ubuntu-latest-conda.yml' './latest/passed/'
- name: Open Pull Request to update latest env files
id: env-updates-pr
uses: qiime2/create-pull-request@v5
with:
token: ${{ secrets.BOT_PAT }}
branch: update-latest-envs-from-PR-${{ needs.create-pr.outputs.pr }}
title: "[${{ inputs.distro }}] latest env updates from PR ${{ needs.create-pr.outputs.pr }}"
add-paths: ./latest/passed/
body: |
Automated updates to latest env files from `create-prepare-pr.yaml`
triggered by ${{ github.event_name }}.
author: "q2d2 <[email protected]>"
committer: "q2d2 <[email protected]>"
commit-message: |
Automated updates to latest resolved environment files: ${{ needs.create-pr.outputs.epoch }} ${{ inputs.distro }}
merge-latest-env-pr:
needs: [update-latest-envs]
runs-on: ubuntu-latest
steps:
- name: merge env updates
id: merge-env-pr
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api \
--method PUT \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/qiime2/distributions/pulls/${{ needs.update-latest-envs.outputs.env-pr }}/merge