.github/workflows/e2e.yml
name: 'e2e Tests'
on:
workflow_call:
inputs:
pr-trigger:
description: 'True if tests were triggered by a PR'
default: false
required: true
type: boolean
jobs:
e2e:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: Docker Hub e2e
image: mrsmithers/hello-world
dockerfile: ./e2e/Dockerfile
registry: docker.io
username: DOCKERHUB_USERNAME
password: DOCKERHUB_PASSWORD
addLatest: true
labels: org.opencontainers.image.description="A Hello World image used for e2e tests"
- name: Multi-platform e2e
image: mrsmithers/hello-world
dockerfile: ./e2e/Dockerfile
registry: docker.io
username: DOCKERHUB_USERNAME
password: DOCKERHUB_PASSWORD
multiPlatform: true
platform: linux/amd64,linux/arm64,linux/arm/v7
- name: GCR e2e
image: orbital-bank-301021/hello-world
dockerfile: ./e2e/Dockerfile
registry: gcr.io
username: GCR_USERNAME
password: GCR_PASSWORD
labels: org.opencontainers.image.description="A Hello World image used for e2e tests"
- name: ECR e2e
image: hello-world
dockerfile: ./e2e/test-build-dir/Dockerfile
directory: e2e/test-build-dir
registry: 026181534292.dkr.ecr.us-west-2.amazonaws.com
buildArgs: TEST=true
- name: GHCR Legacy e2e
image: docker-build-push/e2e-image
dockerfile: ./e2e/Dockerfile
registry: docker.pkg.github.com
username: GH_USERNAME
password: GITHUB_TOKEN
- name: GHCR e2e
image: hello-world
dockerfile: ./e2e/multi.Dockerfile
target: prod
registry: ghcr.io
githubOrg: docker-action-e2e
username: GHCR_USERNAME
password: GHCR_TOKEN
steps:
- name: Check out code current branch
if: ${{ !inputs.pr-trigger }}
uses: actions/checkout@v3
- name: Check out merge code
if: ${{ inputs.pr-trigger }}
uses: actions/checkout@v3
with:
ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
- name: Create check run
if: ${{ inputs.pr-trigger }}
uses: actions/github-script@v7
env:
name: ${{ matrix.name }}
number: ${{ github.event.client_payload.pull_request.number }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pull } = await github.rest.pulls.get({
...context.repo,
pull_number: process.env.number
});
const sha = pull.head.sha;
const { data: check } = await github.rest.checks.create({
...context.repo,
name: process.env.name,
head_sha: sha
});
return check;
- name: Build and push Docker image
id: docker
uses: ./
with:
image: ${{ matrix.image }}
tags: ${{ github.run_id }}
addLatest: ${{ matrix.addLatest }}
addTimestamp: ${{ matrix.addTimestamp }}
registry: ${{ matrix.registry }}
dockerfile: ${{ matrix.dockerfile }}
directory: ${{ matrix.directory }}
buildArgs: ${{ matrix.buildArgs }}
labels: ${{ matrix.labels }}
target: ${{ matrix.target }}
username: ${{ secrets[matrix.username] }}
password: ${{ secrets[matrix.password] }}
githubOrg: ${{ matrix.githubOrg }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Verify Docker image
run: |
docker pull ${{ steps.docker.outputs.imageFullName }}:${{ github.run_id }}
docker image inspect ${{ steps.docker.outputs.imageFullName }}:${{ github.run_id }}
- name: Update check run
if: ${{ inputs.pr-trigger }}
uses: actions/github-script@v7
env:
number: ${{ github.event.client_payload.pull_request.number }}
job: ${{ github.job }}
conclusion: ${{ job.status }}
name: ${{ matrix.name }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pull } = await github.rest.pulls.get({
...context.repo,
pull_number: process.env.number
});
const ref = pull.head.sha;
const { data: checks } = await github.rest.checks.listForRef({
...context.repo,
ref
});
const check = checks.check_runs.filter(c => c.name === process.env.name);
const { data: result } = await github.rest.checks.update({
...context.repo,
check_run_id: check[0].id,
status: 'completed',
conclusion: process.env.conclusion
});
return result;
- name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v2