Test Action (Integration) #2748
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Test Action (Integration)" | |
on: | |
schedule: | |
- cron: "*/37 12 * * *" | |
push: | |
branches: | |
- "**" | |
env: | |
registry: ghcr.io | |
repository: "${{ github.repository }}" | |
tag: "test-${{ github.run_id }}" | |
image-writable: "ghcr.io/${{ github.repository }}:test-${{ github.run_id }}" | |
image-unwritable: "ghcr.io/${{ github.repository }}-unwritable:test-${{ github.run_id }}" | |
username: "${{ github.repository_owner }}" | |
password: "${{ github.token }}" | |
token: "${{ github.token }}" | |
jobs: | |
tag-example-image: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Javascript dependencies via npm | |
if: ${{ github.ref != 'refs/heads/release' }} | |
run: npm install | |
- name: Package action for integration tests | |
if: ${{ github.ref != 'refs/heads/release' }} | |
run: npm run package | |
- name: Log In to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: "${{ env.registry }}" | |
username: "${{ env.username }}" | |
password: "${{ env.password }}" | |
- name: Add example image to container registry for test repository | |
run: | | |
docker pull hello-world | |
docker tag hello-world ${{ env.image-writable }} | |
docker push ${{ env.image-writable }} | |
- name: Add One Tag | |
uses: ./ | |
with: | |
registry: "${{ env.registry }}" | |
repository: "${{ env.repository }}" | |
target: "${{ env.tag }}" | |
tags: "${{ env.tag }}-single" | |
- name: Add Multiple Tags | |
uses: ./ | |
with: | |
registry: "${{ env.registry }}" | |
repository: "${{ env.repository }}" | |
target: "${{ env.tag }}" | |
tags: | | |
${{ env.tag }}-multiple-a | |
${{ env.tag }}-multiple-b | |
- name: Add example OCI image to container registry | |
run: | | |
token=$(echo -n $token | base64) | |
skopeo copy --all \ | |
"docker://docker.io/library/hello-world:latest" \ | |
"docker://${{ env.image-writable }}-oci" \ | |
--dest-registry-token $token \ | |
-f oci | |
- name: Add signle tag to OCI image | |
uses: ./ | |
with: | |
registry: "${{ env.registry }}" | |
repository: "${{ env.repository }}" | |
target: "${{ env.tag }}-oci" | |
tags: "${{ env.tag }}-oci-single" | |
assert-tags-exist: | |
runs-on: ubuntu-latest | |
needs: | |
- tag-example-image | |
strategy: | |
matrix: | |
include: | |
- tag: single | |
version: "docker.distribution.manifest.v2" | |
- tag: multiple-a | |
version: "docker.distribution.manifest.v2" | |
- tag: multiple-b | |
version: "docker.distribution.manifest.v2" | |
- tag: oci-single | |
version: "oci.image.index.v1" | |
fail-fast: false | |
env: | |
repository: "https://ghcr.io/v2/${{ github.repository }}" | |
tag: "test-${{ github.run_id }}-${{ matrix.tag }}" | |
version: "${{ matrix.version }}" | |
steps: | |
- name: Assert image has tag ${{ matrix.tag }} | |
run: | | |
token=$(echo -n $token | base64) | |
curl -sf $repository/manifests/$tag \ | |
-H "Authorization: Bearer $token" \ | |
-H "Accept: application/vnd.$version+json" \ | |
|| (echo "::error::$tag not found" && exit 1) | |
try-to-tag-unwritable-image: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Log In to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: "${{ env.registry }}" | |
username: "${{ env.username }}" | |
password: "${{ env.password }}" | |
- id: write-image | |
name: Attempt to write image that cannot be written to | |
continue-on-error: true | |
run: | | |
docker pull hello-world | |
docker tag hello-world ${{ env.image-unwritable }} | |
docker push ${{ env.image-unwritable }} | |
- if: steps.write-image.outcome != 'failure' | |
uses: actions/github-script@v3 | |
with: | |
script: core.setFailed('Did not throw error when trying to write an unwritable image') |