Scan For New Associations #35
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run every third day starting from the 2nd of the month 1 am pacific | |
# check for new collection associations to the concise 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/concise/*_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.outputs.new_uat_associations }} | |
new_ops_associations: ${{ steps.diff.outputs.new_ops_associations }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install Poetry | |
uses: abatilo/actions-poetry@v3 | |
with: | |
poetry-version: 1.5.1 | |
- name: Run diff | |
id: diff | |
env: | |
UAT_TOKEN_TEMP: ${{ secrets.LAUNCHPAD_TOKEN_UAT }} | |
OPS_TOKEN_TEMP: ${{ secrets.LAUNCHPAD_TOKEN_OPS }} | |
run: | | |
poetry install | |
ls $GITHUB_WORKSPACE/tests/cmr/concise/uat/ > uat_associations.txt | |
ls $GITHUB_WORKSPACE/tests/cmr/concise/ops/ > ops_associations.txt | |
poetry run cmr_association_diff -e uat -t service -p POCLOUD -n 'PODAAC Concise' -a uat_associations.txt --token $UAT_TOKEN_TEMP > new_uat_associations.txt | |
poetry run cmr_association_diff -e ops -t service -p POCLOUD -n 'PODAAC Concise' -a ops_associations.txt --token $OPS_TOKEN_TEMP > new_ops_associations.txt | |
echo "new_uat_associations=$(poetry run python tests/collection_names.py --env uat --token $UAT_TOKEN_TEMP --file new_uat_associations.txt)" >> $GITHUB_OUTPUT | |
echo "new_ops_associations=$(poetry run python tests/collection_names.py --env ops --token $OPS_TOKEN_TEMP --file new_ops_associations.txt)" >> $GITHUB_OUTPUT | |
rm *_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: Update uat_associations | |
run: | | |
mkdir -p $GITHUB_WORKSPACE/tests/cmr/concise/uat | |
echo "${{ matrix.data.concept_id }}" > $GITHUB_WORKSPACE/tests/cmr/concise/uat/${{ matrix.data.concept_id }} | |
- name: Create Pull Request for ${{ env.SHORT_NAME }} | |
id: cpr | |
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 concise and ${{ matrix.data.concept_id }} found in UAT. | |
Beginning verification of collection. | |
labels: | | |
unverified | |
autotest | |
- name: Enable Pull Request Automerge | |
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: Update ops_associations | |
run: | | |
mkdir -p $GITHUB_WORKSPACE/tests/cmr/concise/ops | |
echo "${{ matrix.data.concept_id }}" > $GITHUB_WORKSPACE/tests/cmr/concise/ops/${{ matrix.data.concept_id }} | |
- name: Create Pull Request for ${{ env.SHORT_NAME }} | |
id: cpr | |
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 concise and ${{ matrix.data.concept_id }} found in OPS. | |
Beginning verification of collection. | |
labels: | | |
unverified | |
autotest | |
- name: Enable Pull Request Automerge | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: gh pr merge --merge --auto ${{ steps.cpr.outputs.pull-request-number }} | |