-
Notifications
You must be signed in to change notification settings - Fork 2
184 lines (174 loc) · 7.85 KB
/
diff.yml
File metadata and controls
184 lines (174 loc) · 7.85 KB
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# Run every third day starting from the 2nd of the month 1 am pacific
# check for new collection associations to the l2ss-py UMM-S record
# in UAT and OPS. If a new association is found, a PR is opened to add the new collection concept id to the
# cmr/l2ss-py/*_associations.txt file.
name: Scan For New Associations
on:
workflow_dispatch:
schedule:
- cron: '0 8 2-31/3 * *'
jobs:
find_new:
name: Find new associations
runs-on: ubuntu-latest
outputs:
new_uat_associations: ${{ steps.diff_uat.outputs.new_uat_associations }}
new_ops_associations: ${{ steps.diff_ops.outputs.new_ops_associations }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install Poetry
uses: abatilo/actions-poetry@v3
with:
poetry-version: 2.3.2
- name: Get OPS token
id: ops_token
uses: ./.github/workflows/launchpad-token
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_CUMULUS_OPS }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_CUMULUS_OPS }}
lambda-function: ops-launchpad_token_dispenser
- name: Get UAT token
id: uat_token
uses: ./.github/workflows/launchpad-token
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_CUMULUS_UAT }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_CUMULUS_UAT }}
lambda-function: uat-launchpad_token_dispenser
- name: Install l2ss-py-autotest
run: |
poetry install
- name: Run diff in UAT
env:
UAT_TOKEN_TEMP: ${{ steps.uat_token.outputs.result }}
id: diff_uat
run: |
ls $GITHUB_WORKSPACE/tests/cmr/l2ss-py/uat/ > $GITHUB_WORKSPACE/tests/cmr/l2ss-py/uat_associations.txt
poetry run cmr_association_diff -e uat -t service -p POCLOUD -n 'PODAAC L2 Cloud Subsetter' -a $GITHUB_WORKSPACE/tests/cmr/l2ss-py/uat_associations.txt --token $UAT_TOKEN_TEMP > $GITHUB_WORKSPACE/tests/cmr/l2ss-py/new_uat_associations.txt
echo "new_uat_associations=$(poetry run python tests/collection_names.py --env uat --token $UAT_TOKEN_TEMP --file $GITHUB_WORKSPACE/tests/cmr/l2ss-py/new_uat_associations.txt)" >> $GITHUB_OUTPUT
rm $GITHUB_WORKSPACE/tests/cmr/l2ss-py/uat_associations.txt
rm $GITHUB_WORKSPACE/tests/cmr/l2ss-py/new_uat_associations.txt
- name: Run diff in OPS
id: diff_ops
env:
OPS_TOKEN_TEMP: ${{ steps.ops_token.outputs.result }}
run: |
ls $GITHUB_WORKSPACE/tests/cmr/l2ss-py/ops/ > $GITHUB_WORKSPACE/tests/cmr/l2ss-py/ops_associations.txt
poetry run cmr_association_diff -e ops -t service -p POCLOUD -n 'PODAAC L2 Cloud Subsetter' -a $GITHUB_WORKSPACE/tests/cmr/l2ss-py/ops_associations.txt --token $OPS_TOKEN_TEMP > $GITHUB_WORKSPACE/tests/cmr/l2ss-py/new_ops_associations.txt
echo "new_ops_associations=$(poetry run python tests/collection_names.py --env ops --token $OPS_TOKEN_TEMP --file $GITHUB_WORKSPACE/tests/cmr/l2ss-py/new_ops_associations.txt)" >> $GITHUB_OUTPUT
rm $GITHUB_WORKSPACE/tests/cmr/l2ss-py/ops_associations.txt
rm $GITHUB_WORKSPACE/tests/cmr/l2ss-py/new_ops_associations.txt
open_pr_uat:
needs: find_new
strategy:
fail-fast: false
max-parallel: 2
matrix:
data: ${{fromJson(needs.find_new.outputs.new_uat_associations)}}
runs-on: ubuntu-latest
name: UAT ${{ matrix.data.concept_id }} ${{ matrix.data.short_name }}
steps:
- uses: getsentry/action-github-app-token@v3
name: Get GH App token
id: podaac-cicd
with:
app_id: ${{ secrets.CICD_APP_ID }}
private_key: ${{ secrets.CICD_APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
- name: Check for existing PR
id: existing_pr
env:
GH_TOKEN: ${{ steps.podaac-cicd.outputs.token }}
run: |
pr_count=$(gh pr list --head "diff/uat/${{ matrix.data.concept_id }}" --state open --json number --jq 'length')
if [ "$pr_count" -gt 0 ]; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Update uat_associations
if: steps.existing_pr.outputs.exists != 'true'
run: |
mkdir -p $GITHUB_WORKSPACE/tests/cmr/l2ss-py/uat
echo "${{ matrix.data.concept_id }}" > $GITHUB_WORKSPACE/tests/cmr/l2ss-py/uat/${{ matrix.data.concept_id }}
- name: Create Pull Request for ${{ env.SHORT_NAME }}
id: cpr
if: steps.existing_pr.outputs.exists != 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ steps.podaac-cicd.outputs.token }}
commit-message: Add ${{ matrix.data.concept_id }}
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
branch: diff/uat/${{ matrix.data.concept_id }}
delete-branch: true
title: UAT ${{ matrix.data.concept_id }} (${{ matrix.data.short_name }})
body: |
New association between l2ss-py and ${{ matrix.data.concept_id }} found in UAT.
Beginning verification of collection.
labels: |
unverified
autotest
- name: Enable Pull Request Automerge
if: steps.existing_pr.outputs.exists != 'true'
env:
GH_TOKEN: ${{ github.token }}
run: gh pr merge --merge --auto ${{ steps.cpr.outputs.pull-request-number }}
open_pr_ops:
needs: find_new
strategy:
fail-fast: false
max-parallel: 2
matrix:
data: ${{fromJson(needs.find_new.outputs.new_ops_associations)}}
runs-on: ubuntu-latest
name: OPS ${{ matrix.data.concept_id }} ${{ matrix.data.short_name }}
steps:
- uses: getsentry/action-github-app-token@v3
name: Get GH App token
id: podaac-cicd
with:
app_id: ${{ secrets.CICD_APP_ID }}
private_key: ${{ secrets.CICD_APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
- name: Check for existing PR
id: existing_pr
env:
GH_TOKEN: ${{ steps.podaac-cicd.outputs.token }}
run: |
pr_count=$(gh pr list --head "diff/ops/${{ matrix.data.concept_id }}" --state open --json number --jq 'length')
if [ "$pr_count" -gt 0 ]; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Update ops_associations
if: steps.existing_pr.outputs.exists != 'true'
run: |
mkdir -p $GITHUB_WORKSPACE/tests/cmr/l2ss-py/ops
echo "${{ matrix.data.concept_id }}" > $GITHUB_WORKSPACE/tests/cmr/l2ss-py/ops/${{ matrix.data.concept_id }}
- name: Create Pull Request for ${{ env.SHORT_NAME }}
id: cpr
if: steps.existing_pr.outputs.exists != 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ steps.podaac-cicd.outputs.token }}
commit-message: Add ${{ matrix.data.concept_id }}
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
branch: diff/ops/${{ matrix.data.concept_id }}
delete-branch: true
title: OPS ${{ matrix.data.concept_id }} (${{ matrix.data.short_name }})
body: |
New association between l2ss-py and ${{ matrix.data.concept_id }} found in OPS.
Beginning verification of collection.
labels: |
unverified
autotest
- name: Enable Pull Request Automerge
if: steps.existing_pr.outputs.exists != 'true'
env:
GH_TOKEN: ${{ github.token }}
run: gh pr merge --merge --auto ${{ steps.cpr.outputs.pull-request-number }}