-
Notifications
You must be signed in to change notification settings - Fork 29
76 lines (66 loc) · 2.08 KB
/
docker.yml
File metadata and controls
76 lines (66 loc) · 2.08 KB
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
name: Create and publish a Docker image
on:
workflow_dispatch:
push:
branches: ['main', 'staging']
tags: ['v*']
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: ${{ github.ref }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to the Container registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get tags
id: tags
env:
IMAGE_NAME: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
run: |
echo "value<<EOF" >> $GITHUB_OUTPUT
./docker/get-docker-tags.sh "$(date -u +%F)" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
shell: bash
- name: Build Docker image (amd64, for smoke test)
uses: docker/build-push-action@v7
with:
platforms: linux/amd64
context: .
load: true
file: ./Dockerfile
tags: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:smoke-test"
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Smoke-test Docker image
run: |
for i in {1..3}; do
timeout 15s docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:smoke-test --version && break || [ $i = 3 ] && exit 1
done
timeout-minutes: 1
- name: Build and push multi-platform Docker image
uses: docker/build-push-action@v7
with:
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
context: .
push: true
file: ./Dockerfile
tags: "${{ steps.tags.outputs.value }}"
cache-from: type=gha
cache-to: type=gha,mode=max