Skip to content

Commit f82f4c3

Browse files
feat(ci): add EU system-identity cleanup job
Mirrors cleanup-system-identity for EU. Without this, any EU system identity created by create-system-identity-eu in a PR would be orphaned in the EU NerdGraph customerAdministration plane. Same shape as the US cleanup: writes EU config, extracts NR API key, issues systemIdentityDelete against api.eu.newrelic.com for the ID emitted by create-system-identity-eu. continue-on-error so a delete failure doesn't fail the whole workflow.
1 parent 7b5795f commit f82f4c3

1 file changed

Lines changed: 42 additions & 1 deletion

File tree

.github/workflows/validation.yml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,50 @@ jobs:
537537
echo "Config file not found, skipping system identity cleanup"
538538
fi
539539
540+
cleanup-system-identity-eu:
541+
name: Cleanup System Identity (EU)
542+
runs-on: ubuntu-latest
543+
needs: [test-deploy-recipe, get-test-definition-files, create-system-identity-eu]
544+
if: always() && needs.get-test-definition-files.outputs.needs_system_identity_eu == 'true'
545+
steps:
546+
- name: Checkout Repo
547+
uses: actions/checkout@v2
548+
with:
549+
fetch-depth: 0
550+
551+
- name: Write Test Definition File JSON to file (EU)
552+
env:
553+
USER_JSON: ${{ secrets.GIT_DEPLOYER_DOCKER_USER_CONFIG_EU }}
554+
run: |
555+
mkdir -p configs
556+
echo "$USER_JSON" > configs/gitusdkr${{ github.run_id }}.json
557+
558+
- name: Clean up system identity (EU)
559+
continue-on-error: true
560+
run: |
561+
if [ -f configs/gitusdkr${{ github.run_id }}.json ]; then
562+
NR_API_KEY=$(jq -r -e '.credentials.newrelic.nrPersonalApiKey' configs/gitusdkr${{ github.run_id }}.json)
563+
SYSTEM_IDENTITY_ID="${{ needs.create-system-identity-eu.outputs.SYSTEM_IDENTITY_ID }}"
564+
echo "::add-mask::$NR_API_KEY"
565+
echo "::add-mask::$SYSTEM_IDENTITY_ID"
566+
if [ ! -z "$SYSTEM_IDENTITY_ID" ] && [ "$SYSTEM_IDENTITY_ID" != "null" ]; then
567+
echo "Cleaning up EU system identity with ID: $SYSTEM_IDENTITY_ID"
568+
curl -X POST https://api.eu.newrelic.com/graphql \
569+
-H 'content-type: application/json; charset=utf-8' \
570+
-H "API-Key: $NR_API_KEY" \
571+
--data-raw "{
572+
\"query\": \"mutation { systemIdentityDelete(id: \\\"$SYSTEM_IDENTITY_ID\\\") { id } }\"
573+
}" || echo "Failed to delete EU system identity, it may have already been deleted"
574+
else
575+
echo "No EU system identity to clean up"
576+
fi
577+
else
578+
echo "EU config file not found, skipping system identity cleanup"
579+
fi
580+
540581
slack-notify:
541582
runs-on: ubuntu-latest
542-
needs: [test-deploy-recipe, cleanup-system-identity]
583+
needs: [test-deploy-recipe, cleanup-system-identity, cleanup-system-identity-eu]
543584
if: always()
544585
steps:
545586
- name: Build Result Slack Notification

0 commit comments

Comments
 (0)