-
-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (144 loc) · 5.76 KB
/
docker-push.yml
File metadata and controls
168 lines (144 loc) · 5.76 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
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
159
160
161
162
163
164
165
166
167
168
name: Multi-Architecture Docker Build
on:
push:
branches:
- '**'
permissions:
contents: read
packages: write
jobs:
build-push-amd64:
runs-on: ubuntu-latest
name: Build AMD64 Image
steps:
- name: Check out the repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Extract repository name and branch
id: repo-info
run: |
REPO_NAME=$(echo "${{ github.repository }}" | awk -F '/' '{print $2}' | tr '[:upper:]' '[:lower:]')
REPO_OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
BRANCH_NAME=$(echo "${{ github.ref_name }}" | tr '/' '-' | tr '[:upper:]' '[:lower:]')
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV
echo "REPO_OWNER=$REPO_OWNER" >> $GITHUB_ENV
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Set up Docker Context for Buildx
id: buildx-context
run: |
docker context create builders
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: latest
endpoint: builders
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push AMD64 Docker image
uses: docker/build-push-action@v3
with:
context: .
file: ./docker/Dockerfile
platforms: linux/amd64
push: true
provenance: false
tags: |
ghcr.io/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}:latest-amd64
ghcr.io/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}:${{ github.sha }}-amd64
ghcr.io/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}:${{ env.BRANCH_NAME }}-amd64
build-push-arm64:
runs-on: ubuntu-24.04-arm
name: Build ARM64 Image
steps:
- name: Check out the repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Extract repository name and branch
id: repo-info
run: |
REPO_NAME=$(echo "${{ github.repository }}" | awk -F '/' '{print $2}' | tr '[:upper:]' '[:lower:]')
REPO_OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
BRANCH_NAME=$(echo "${{ github.ref_name }}" | tr '/' '-' | tr '[:upper:]' '[:lower:]')
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV
echo "REPO_OWNER=$REPO_OWNER" >> $GITHUB_ENV
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Set up Docker Context for Buildx
id: buildx-context
run: |
docker context create builders
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: latest
endpoint: builders
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push ARM64 Docker image
uses: docker/build-push-action@v3
with:
context: .
file: ./docker/Dockerfile
platforms: linux/arm64
push: true
provenance: false
tags: |
ghcr.io/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}:latest-arm64
ghcr.io/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}:${{ github.sha }}-arm64
ghcr.io/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}:${{ env.BRANCH_NAME }}-arm64
create-manifests:
runs-on: ubuntu-latest
needs: [build-push-amd64, build-push-arm64]
name: Create Multi-Arch Manifest
steps:
- name: Check out the repository
uses: actions/checkout@v3
- name: Extract repository name and branch
run: |
REPO_NAME=$(echo "${{ github.repository }}" | awk -F '/' '{print $2}' | tr '[:upper:]' '[:lower:]')
REPO_OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
BRANCH_NAME=$(echo "${{ github.ref_name }}" | tr '/' '-' | tr '[:upper:]' '[:lower:]')
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV
echo "REPO_OWNER=$REPO_OWNER" >> $GITHUB_ENV
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Enable Docker experimental features
run: |
mkdir -p $HOME/.docker
echo '{"experimental": "enabled"}' > $HOME/.docker/config.json
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create SHA manifest and push
run: |
# Using buildx imagetools instead of docker manifest
docker buildx imagetools create \
-t ghcr.io/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}:${{ github.sha }} \
ghcr.io/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}:${{ github.sha }}-amd64 \
ghcr.io/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}:${{ github.sha }}-arm64
- name: Create branch manifest and push
run: |
# Using buildx imagetools instead of docker manifest
docker buildx imagetools create \
-t ghcr.io/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}:${{ env.BRANCH_NAME }} \
ghcr.io/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}:${{ env.BRANCH_NAME }}-amd64 \
ghcr.io/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}:${{ env.BRANCH_NAME }}-arm64
- name: Create latest manifest and push
if: github.ref == 'refs/heads/main'
run: |
# Using buildx imagetools instead of docker manifest
docker buildx imagetools create \
-t ghcr.io/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}:latest \
ghcr.io/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}:latest-amd64 \
ghcr.io/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}:latest-arm64