-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (130 loc) · 4.37 KB
/
docker-publish.yml
File metadata and controls
145 lines (130 loc) · 4.37 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
name: Docker (TEST)
on:
push:
paths:
- 'Dockerfile'
workflow_dispatch:
env:
REGISTRY_GHCR: ghcr.io
REGISTRY_DOCKER: docker.io
IMAGE_NAME: ${{ github.repository }}
jobs:
set-up:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
outputs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
steps:
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY_GHCR }}/${{ env.IMAGE_NAME }}
${{ env.REGISTRY_DOCKER }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value={{date 'YYYYMMDD-HHmmss' tz='Asia/Seoul'}}
labels: |
maintainer=your-email@example.com
flavor: |
latest=true
build:
needs: [set-up]
strategy:
matrix:
platform: [amd64, arm64]
runs-on:
- linux
- ${{ matrix.platform }}
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Set version based on tag
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ env.RELEASE_VERSION }}
- name: Set Clean Version
run: |
CLEAN_VERSION="${{ env.RELEASE_VERSION }}"
echo "VERSION=${CLEAN_VERSION}" >> $GITHUB_ENV
- name: Convert IMAGE_NAME to lowercase
run: |
LOWER_CASE_IMAGE_NAME=$(echo "${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]')
echo "LOWER_CASE=${LOWER_CASE_IMAGE_NAME}" >> $GITHUB_ENV
- name: Log into GitHub Container Registry (GHCR)
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY_GHCR }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log into Docker Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY_DOCKER }}
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push to GHCR
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.REGISTRY_GHCR }}/${{ env.LOWER_CASE }}:${{ matrix.platform }}
labels: ${{ needs.set-up.outputs.labels }}
platforms: linux/${{ matrix.platform }}
- name: Build and push to Docker Hub
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.REGISTRY_DOCKER }}/${{ env.LOWER_CASE }}:${{ matrix.platform }}
labels: ${{ needs.set-up.outputs.labels }}
platforms: linux/${{ matrix.platform }}
manifest:
needs: [set-up, build]
runs-on: [linux, ARM64]
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Log into GitHub Container Registry (GHCR)
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY_GHCR }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log into Docker Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY_DOCKER }}
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Convert IMAGE_NAME to lowercase
run: |
LOWER_CASE_IMAGE_NAME=$(echo "${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]')
echo "IMAGE_NAME_LOWER=${LOWER_CASE_IMAGE_NAME}" >> $GITHUB_ENV
- name: Create and push Docker manifest
uses: int128/docker-manifest-create-action@v2
with:
index-annotations: |
${{ needs.set-up.outputs.labels }}
tags: |
${{ needs.set-up.outputs.tags }}
sources: |
${{ env.REGISTRY_GHCR }}/${{ env.IMAGE_NAME_LOWER }}:amd64
${{ env.REGISTRY_GHCR }}/${{ env.IMAGE_NAME_LOWER }}:arm64