Skip to content

Commit 467e08c

Browse files
committed
Moved Playwright GHCR image check to setup job and removed standalone workflow
1 parent a5284f3 commit 467e08c

File tree

4 files changed

+17
-74
lines changed

4 files changed

+17
-74
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,18 @@ jobs:
200200
set -euo pipefail
201201
202202
PLAYWRIGHT_VERSION="$(node -p "require('./e2e/package.json').devDependencies['@playwright/test']")"
203-
BASE_PLAYWRIGHT_VERSION="$(git show "${BASE_COMMIT}:e2e/package.json" | node -p "JSON.parse(require('fs').readFileSync(0, 'utf8')).devDependencies['@playwright/test']")"
204-
PLAYWRIGHT_VERSION_CHANGED=false
203+
echo "version=$PLAYWRIGHT_VERSION" >> "$GITHUB_OUTPUT"
205204
206-
if [ "$PLAYWRIGHT_VERSION" != "$BASE_PLAYWRIGHT_VERSION" ]; then
207-
PLAYWRIGHT_VERSION_CHANGED=true
208-
fi
205+
# Check if the image already exists in GHCR (anonymous OCI registry check)
206+
TOKEN="$(curl -sf "https://ghcr.io/token?service=ghcr.io&scope=repository:tryghost/playwright:pull" | jq -r .token)" || TOKEN=""
207+
HTTP_CODE="$(curl -so /dev/null -w "%{http_code}" -H "Authorization: Bearer $TOKEN" \
208+
"https://ghcr.io/v2/tryghost/playwright/manifests/v${PLAYWRIGHT_VERSION}-noble")"
209209
210-
echo "version=$PLAYWRIGHT_VERSION" >> "$GITHUB_OUTPUT"
211-
echo "version-changed=$PLAYWRIGHT_VERSION_CHANGED" >> "$GITHUB_OUTPUT"
210+
if [ "$HTTP_CODE" = "200" ]; then
211+
echo "image-exists=true" >> "$GITHUB_OUTPUT"
212+
else
213+
echo "image-exists=false" >> "$GITHUB_OUTPUT"
214+
fi
212215
213216
214217
outputs:
@@ -236,50 +239,37 @@ jobs:
236239
node_version: ${{ env.NODE_VERSION }}
237240
node_test_matrix: ${{ steps.node_matrix.outputs.matrix }}
238241
playwright_version: ${{ steps.playwright.outputs.version }}
239-
playwright_version_changed: ${{ steps.playwright.outputs.version-changed }}
242+
playwright_image_exists: ${{ steps.playwright.outputs.image-exists }}
240243

241244
job_mirror_playwright_image:
242245
name: Mirror Playwright image
243246
runs-on: ubuntu-latest
244247
needs: [job_setup]
245-
if: needs.job_setup.outputs.is_tag != 'true' && needs.job_setup.outputs.playwright_version_changed == 'true'
248+
if: needs.job_setup.outputs.is_tag != 'true' && needs.job_setup.outputs.playwright_image_exists != 'true'
246249
permissions:
247250
contents: read
248251
packages: write
249252
steps:
250253
- name: Checkout
251254
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
252255

253-
- name: Check Playwright image in GHCR
254-
id: playwright-image
255-
env:
256-
PLAYWRIGHT_IMAGE: ghcr.io/tryghost/playwright:v${{ needs.job_setup.outputs.playwright_version }}-noble
257-
run: |
258-
set -euo pipefail
259-
260-
if docker manifest inspect "$PLAYWRIGHT_IMAGE" > /dev/null 2>&1; then
261-
echo "exists=true" >> "$GITHUB_OUTPUT"
262-
else
263-
echo "exists=false" >> "$GITHUB_OUTPUT"
264-
fi
265-
266256
- name: Login to GHCR
267-
if: steps.playwright-image.outputs.exists != 'true' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
257+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
268258
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4
269259
with:
270260
registry: ghcr.io
271261
username: ${{ github.actor }}
272262
password: ${{ secrets.GITHUB_TOKEN }}
273263

274264
- name: Mirror Playwright image
275-
if: steps.playwright-image.outputs.exists != 'true' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
265+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
276266
uses: ./.github/actions/mirror-container-image
277267
with:
278268
source-image: mcr.microsoft.com/playwright:v${{ needs.job_setup.outputs.playwright_version }}-noble
279269
target-image: ghcr.io/tryghost/playwright:v${{ needs.job_setup.outputs.playwright_version }}-noble
280270

281271
- name: Fail when Playwright image cannot be mirrored
282-
if: steps.playwright-image.outputs.exists != 'true' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
272+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
283273
run: |
284274
echo "::error::Playwright v${{ needs.job_setup.outputs.playwright_version }}-noble is not mirrored in GHCR yet. Publish ghcr.io/tryghost/playwright:v${{ needs.job_setup.outputs.playwright_version }}-noble before running E2E for this branch."
285275
exit 1

.github/workflows/publish-playwright-image.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)