-
Notifications
You must be signed in to change notification settings - Fork 15
157 lines (139 loc) · 5.67 KB
/
docker.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
name: Docker
on:
push:
branches: [ master ]
paths-ignore:
- '**/README.md'
- '.github/workflows/weekly-fuzz.yml'
- 'docs/**'
release:
types: [ published ]
workflow_dispatch:
inputs:
docker_tag:
description: 'value to use for override the image tag; <tag> will still be used for checkout'
required: false
tag:
description: 'git tag to checkout'
required: true
# default: ''
jobs:
build:
name: build and test container image
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: 'wait for tests'
uses: lewagon/[email protected]
with:
ref: ${{ github.ref }}
check-name: 'go test & build'
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
- name: checkout
uses: actions/checkout@v4
if: github.event_name != 'workflow_dispatch'
- name: checkout given tag
uses: actions/checkout@v4
if: github.event_name == 'workflow_dispatch'
with:
ref: ${{ github.event.inputs.tag }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and load docker image
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' || (github.ref == 'refs/heads/master' && github.event_name == 'push')
uses: docker/build-push-action@v2
with:
context: .
load: true
tags: 'couper-test-${{ github.ref }}'
- name: Test container serves index.html
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' || (github.ref == 'refs/heads/master' && github.event_name == 'push')
run: |
docker run -d --rm -p 8080:8080 'couper-test-${{ github.ref }}'
[[ $(curl --head --location --connect-timeout 5 --write-out %{http_code} --silent --output /dev/null http://localhost:8080/) == 200 ]]
publish:
needs: build
name: build and publish container image
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
include:
- image: 'coupergateway/couper'
username_key: DOCKER_COUPER_GATEWAY_USERNAME
password_key: DOCKER_COUPER_GATEWAY_PASSWORD
steps:
- name: checkout
uses: actions/checkout@v4
if: github.event_name != 'workflow_dispatch'
- name: checkout given tag
uses: actions/checkout@v4
if: github.event_name == 'workflow_dispatch'
with:
ref: 'refs/tags/${{ github.event.inputs.tag }}'
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
${{ matrix.image }}
tags: |
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}},value=${{ github.event.inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.docker_tag == '' }}
type=semver,pattern={{major}}.{{minor}},value=${{ github.event.inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.docker_tag == '' }}
type=edge,branch=master,event=branch,enable=${{ github.event_name != 'workflow_dispatch' }}
type=raw,enable=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.docker_tag != '' }},value=${{ github.event.inputs.docker_tag }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
#registry: ...
username: ${{ secrets[matrix.username_key] }}
password: ${{ secrets[matrix.password_key] }}
- name: Build & push image with edge tag
if: github.ref == 'refs/heads/master' && github.event_name == 'push' # due to release branch, pin to master
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
push: ${{ GitHub.event_name != 'pull_request' }}
- name: Build & push image with specific tag
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
push: ${{ GitHub.event_name != 'pull_request' }}
- name: Docker Hub Description
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.docker_tag == '')
uses: peter-evans/dockerhub-description@v2
with:
readme-filepath: './DOCKER.md'
username: ${{ secrets[matrix.username_key] }}
password: ${{ secrets[matrix.password_key] }}
repository: ${{ matrix.image }}
oidc:
name: trigger couper-oidc-gateway edge build
needs: publish
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
steps:
- run: |
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GH_COUPER_API_TOKEN }}" \
https://api.github.com/repos/coupergateway/couper-oidc-gateway/dispatches \
-d '{"event_type": "edge-build", "client_payload": { "version": "edge" }}'