Scan For New Associations #1
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 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/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/ > $GITHUB_WORKSPACE/tests/cmr/concise/uat_associations.txt | |
ls $GITHUB_WORKSPACE/tests/cmr/concise/ops/ > $GITHUB_WORKSPACE/tests/cmr/concise/ops_associations.txt | |
poetry run cmr_association_diff -e uat -t service -p POCLOUD -n 'PODAAC Concise' -a $GITHUB_WORKSPACE/tests/cmr/concise/uat_associations.txt --token $UAT_TOKEN_TEMP > $GITHUB_WORKSPACE/tests/cmr/concise/new_uat_associations.txt | |
poetry run cmr_association_diff -e ops -t service -p POCLOUD -n 'PODAAC Concise' -a $GITHUB_WORKSPACE/tests/cmr/concise/ops_associations.txt --token $OPS_TOKEN_TEMP > $GITHUB_WORKSPACE/tests/cmr/concise/new_ops_associations.txt | |
echo "new_uat_associations=$(poetry run python tests/collection_names.py --env uat --token $UAT_TOKEN_TEMP --file $GITHUB_WORKSPACE/tests/cmr/concise/new_uat_associations.txt)" >> $GITHUB_OUTPUT | |
echo "new_ops_associations=$(poetry run python tests/collection_names.py --env ops --token $OPS_TOKEN_TEMP --file $GITHUB_WORKSPACE/tests/cmr/concise/new_ops_associations.txt)" >> $GITHUB_OUTPUT | |
rm $GITHUB_WORKSPACE/tests/cmr/concise/uat_associations.txt | |
rm $GITHUB_WORKSPACE/tests/cmr/concise/ops_associations.txt | |
rm $GITHUB_WORKSPACE/tests/cmr/concise/new_uat_associations.txt | |
rm $GITHUB_WORKSPACE/tests/cmr/concise/new_ops_associations.txt | |
open_pr_uat: | |
if: false | |
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 l2ss-py 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: | |
if: false | |
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 l2ss-py 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 }} | |