Skip to content

Commit f72e5fe

Browse files
authored
Ensure get-jfrog-credentials is re-runnable (#45)
The "quasi-unique" workaround described in: https://github.com/hazelcast/docker-actions/blob/e5b499f5d05ce65d27616deffcb30fcb596e6a64/get-jfrog-credentials/action.yml#L24-L30 Does not work when the action is invoked [more than once in the same job](https://github.com/hazelcast/hazelcast-docker/actions/runs/21168691327): > Error: Failed to fetch secret: 'JFROG'. Error: Error: The environment name 'GET_JFROG_CREDENTIALS_JFROG_URL' is already in use. Please use an alias to ensure that each secret has a unique environment name.
1 parent e5b499f commit f72e5fe

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

.github/workflows/test-get-jfrog-credentials.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ jobs:
1212
- name: Checkout repository
1313
uses: actions/checkout@v6
1414

15+
# Run it twice to ensure no env name collisions
16+
- uses: ./get-jfrog-credentials
17+
with:
18+
aws-role-to-assume: ${{ secrets.AWS_HAZELCAST_OIDC_GITHUB_ACTIONS_ROLE_ARN }}
19+
jfrog-oidc-provider-name: ${{ github.repository_owner }}-snapshot-internal
20+
1521
- uses: ./get-jfrog-credentials
1622
id: jfrog
1723
with:

get-jfrog-credentials/action.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,28 @@ runs:
2121
role-to-assume: ${{ inputs.aws-role-to-assume }}
2222
aws-region: 'us-east-1'
2323

24+
# GitHub has no way of uniquely identifying steps within a job, so we must generate a random ID for this invocation
25+
- id: get-random-id
26+
shell: bash
27+
run: |
28+
echo "id=${RANDOM}" >> ${GITHUB_OUTPUT}
29+
2430
- uses: aws-actions/aws-secretsmanager-get-secrets@v2
2531
with:
2632
# Make them quasi-unique to avoid overlapping with other secrets that may exist in the calling workflow
2733
# Workaround lack of https://github.com/aws-actions/aws-secretsmanager-get-secrets/issues/14
2834
secret-ids: |
29-
GET_JFROG_CREDENTIALS_JFROG,JFROG
35+
GET_JFROG_CREDENTIALS_${{ steps.get-random-id.outputs.id }}_JFROG,JFROG
3036
parse-json-secrets: true
3137

3238
- id: get-url
3339
shell: bash
3440
run: |
35-
echo "url=${GET_JFROG_CREDENTIALS_JFROG_URL}" >> ${GITHUB_OUTPUT}
41+
echo "url=${GET_JFROG_CREDENTIALS_${{ steps.get-random-id.outputs.id }}_JFROG_URL}" >> ${GITHUB_OUTPUT}
3642
3743
- id: jfrog
3844
uses: jfrog/setup-jfrog-cli@v4
3945
env:
40-
JF_URL: https://${{ env.GET_JFROG_CREDENTIALS_JFROG_URL }}
46+
JF_URL: https://${{ steps.get-url.outputs.url }}
4147
with:
4248
oidc-provider-name: ${{ inputs.jfrog-oidc-provider-name }}

0 commit comments

Comments
 (0)