Skip to content

Commit 6bc0ca2

Browse files
committed
improve handling of github.event.pull_request.head.ref
1 parent 91b3622 commit 6bc0ca2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

.github/workflows/delete-pr-image.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@ jobs:
1616
steps:
1717
- name: Sanitize branch name to match image tag
1818
id: sanitize
19+
env:
20+
PR_REF: ${{ github.event.pull_request.head.ref }}
1921
run: |
20-
BRANCH="${{ github.event.pull_request.head.ref }}"
21-
TAG="${BRANCH//\//_}"
22+
TAG="${PR_REF//\//_}"
2223
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
2324
2425
- name: Delete image by tag from GHCR
26+
env:
27+
TAG: ${{ steps.sanitize.outputs.tag }}
2528
run: |
2629
gh api "orgs/DataDog/packages/container/dd-trace-dotnet%2Fdd-trace-dotnet/versions" \
27-
--jq ".[] | select(.metadata.container.tags[]? == \"${{ steps.sanitize.outputs.tag }}\") | .id" \
30+
--jq ".[] | select(.metadata.container.tags[]? == \"${TAG}\") | .id" \
2831
| xargs -r -I {} gh api "orgs/DataDog/packages/container/dd-trace-dotnet%2Fdd-trace-dotnet/versions/{}" -X DELETE
29-
echo "Deleted version with tag: ${{ steps.sanitize.outputs.tag }}"
32+
echo "Deleted version with tag: ${TAG}"

0 commit comments

Comments
 (0)