+80
.github/workflows/docker-image.yml
+80
.github/workflows/docker-image.yml
···
1
+
name: Docker
2
+
3
+
on:
4
+
schedule:
5
+
- cron: "38 9 * * *"
6
+
push:
7
+
branches: ["main"]
8
+
tags: ["v*.*.*"]
9
+
pull_request:
10
+
branches: ["main"]
11
+
release:
12
+
types: [published]
13
+
14
+
env:
15
+
REGISTRY: ghcr.io
16
+
IMAGE_NAME: ${{ github.repository }}
17
+
18
+
jobs:
19
+
build:
20
+
runs-on: self-hosted
21
+
permissions:
22
+
contents: read
23
+
packages: write
24
+
id-token: write
25
+
26
+
steps:
27
+
- name: Checkout repository
28
+
uses: actions/checkout@v3
29
+
30
+
- name: Install cosign
31
+
if: github.event_name != 'pull_request'
32
+
uses: sigstore/cosign-installer@v3.7.0
33
+
with:
34
+
cosign-release: "v2.4.1"
35
+
36
+
- name: Setup Docker buildx
37
+
uses: docker/setup-buildx-action@v3
38
+
39
+
- name: Log into registry ${{ env.REGISTRY }}
40
+
if: github.event_name != 'pull_request'
41
+
uses: docker/login-action@v3
42
+
with:
43
+
registry: ${{ env.REGISTRY }}
44
+
username: ${{ github.actor }}
45
+
password: ${{ secrets.GITHUB_TOKEN }}
46
+
47
+
- name: Log in to Docker Hub
48
+
if: github.event_name != 'pull_request'
49
+
uses: docker/login-action@v3
50
+
with:
51
+
username: ${{ secrets.DOCKER_USERNAME }}
52
+
password: ${{ secrets.DOCKER_PASSWORD }}
53
+
54
+
- name: Extract metadata (tags, labels) for Docker
55
+
id: meta
56
+
uses: docker/metadata-action@v5
57
+
with:
58
+
images: |
59
+
${{ env.IMAGE_NAME }}
60
+
${{ env.REGISTRY }}/${{ github.repository }}
61
+
62
+
- name: Build and push Docker image (amd64)
63
+
uses: docker/build-push-action@v6
64
+
with:
65
+
context: .
66
+
file: ./Dockerfile
67
+
platforms: linux/amd64
68
+
push: ${{ github.event_name != 'pull_request' }}
69
+
tags: ${{ steps.meta.outputs.tags }}-amd64
70
+
labels: ${{ steps.meta.outputs.labels }}
71
+
72
+
- name: Build and push Docker image (arm64)
73
+
uses: docker/build-push-action@v6
74
+
with:
75
+
context: .
76
+
file: ./Dockerfile
77
+
platforms: linux/arm64
78
+
push: ${{ github.event_name != 'pull_request' }}
79
+
tags: ${{ steps.meta.outputs.tags }}-arm64
80
+
labels: ${{ steps.meta.outputs.labels }}