diff --git a/.github/workflows/native-image.yml b/.github/workflows/native-image.yml index c8673f0..0183825 100644 --- a/.github/workflows/native-image.yml +++ b/.github/workflows/native-image.yml @@ -66,10 +66,19 @@ jobs: - name: Check if image exists in GHCR id: image-check + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + # Exchange the GitHub token for a GHCR registry JWT + TOKEN=$(curl -s \ + -u "${{ github.actor }}:${GH_TOKEN}" \ + "https://ghcr.io/token?scope=repository:now-chess/now-chess-systems/${{ matrix.module }}:pull&service=ghcr.io" \ + | jq -r .token) + STATUS=$(curl -s -o /dev/null -w "%{http_code}" \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "Authorization: Bearer ${TOKEN}" \ "https://ghcr.io/v2/now-chess/now-chess-systems/${{ matrix.module }}/manifests/${{ steps.version.outputs.version }}") + if [[ "$STATUS" == "200" ]]; then echo "exists=true" >> "$GITHUB_OUTPUT" else