-
Notifications
You must be signed in to change notification settings - Fork 8
93 lines (93 loc) · 2.87 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
name: Publish Docker Image
on:
- push
jobs:
e2e:
uses: ./.github/workflows/e2e.yml
build:
name: Matrix Build Docker Image Digests
needs:
- e2e
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
lfs: true
- name: Generate Docker Metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}/ot-sim
- name: Setup QEMU
uses: docker/setup-qemu-action@v2
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Docker Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push by Digest
id: build
uses: docker/build-push-action@v4
with:
context: .
target: prod
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.output.labels }}
outputs: type=image,name=ghcr.io/${{ github.repository }}/ot-sim,push-by-digest=true,name-canonical=true,push=true
- name: Export Digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload Digest
uses: actions/upload-artifact@v3
with:
name: digests
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
name: Push Docker image to GitHub Packages
needs:
- build
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Download Digests
uses: actions/download-artifact@v3
with:
name: digests
path: /tmp/digests
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}/ot-sim
- name: Login to GitHub Docker Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create Manifest List and Push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf 'ghcr.io/${{ github.repository }}/ot-sim@sha256:%s ' *)
- name: Inspect Image
run: |
docker buildx imagetools inspect ghcr.io/${{ github.repository }}/ot-sim:${{ steps.meta.outputs.version }}