forked from dowjones/tokendito
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.yml
108 lines (104 loc) · 3.63 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
name: Publish to Dockerhub
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
env:
REGISTRY: docker.io
IMAGE_NAME: jpsevigny/jptest
jobs:
dockerbuild:
name: Docker Container
runs-on: ubuntu-latest
strategy:
fail-fast: false
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: jpsevigny
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: amd64 Docker metadata
id: metaamd64
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
suffix=-amd64
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,format=long
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
- name: Build container
uses: docker/build-push-action@v4
with:
platforms: linux/amd64
context: .
push: true
sbom: true
tags: ${{ steps.metaamd64.outputs.tags }}
labels: ${{ steps.metaamd64.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: arm64 Docker metadata
id: metaarm64
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
suffix=-arm64
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,format=long
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
- name: Build container
uses: docker/build-push-action@v4
with:
platforms: linux/arm64
context: .
push: true
sbom: true
tags: ${{ steps.metaarm64.outputs.tags }}
labels: ${{ steps.metaarm64.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# - name: sign images and push
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
# run: |
# mkdir -p ~/.docker/trust/private
# echo "${DOCKER_PRIVATE_KEY}" > ~/.docker/trust/private/${DOCKER_PRIVATE_KEY_ID}.key
# chmod 0600 ~/.docker/trust/private/${DOCKER_PRIVATE_KEY_ID}.key
# docker trust key load ~/.docker/trust/private/${DOCKER_PRIVATE_KEY_ID}.key --name "${DOCKER_PRIVATE_KEY_ID}"
# echo "${{ steps.meta.outputs.tags }}" | xargs -I {} -n 1 docker pull {}
# echo "${{ steps.meta.outputs.tags }}" | xargs -I {} -n 1 docker trust sign {}
# echo "${{ steps.meta.outputs.tags }}" | xargs -I {} -n 1 docker push {}
# env:
# DOCKER_PRIVATE_KEY_ID: "${{ secrets.DOCKER_PRIVATE_KEY_ID }}"
# DOCKER_PRIVATE_KEY: "${{ secrets.DOCKER_PRIVATE_KEY }}"
# DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: "${{ secrets.DOCKER_PRIVATE_KEY_PASSPHRASE }}"
# - name: Verify signatures
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
# run: |
# echo "${{ steps.meta.outputs.tags }}" | xargs -I {} -n 1 docker trust inspect --pretty {}