-
Notifications
You must be signed in to change notification settings - Fork 63
158 lines (144 loc) · 5.25 KB
/
e2e.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
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