-
-
Notifications
You must be signed in to change notification settings - Fork 456
62 lines (52 loc) · 2.03 KB
/
docker-image.yml
File metadata and controls
62 lines (52 loc) · 2.03 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
name: Build Docker Image
on:
release:
types: [published]
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry (ghcr.io)
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set Docker image tags
id: meta
run: |
REPO=ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
if [[ "${{ github.event_name }}" == "release" ]]; then
VERSION_TAG=${{ github.event.release.tag_name }}
echo "tags<<EOF" >> $GITHUB_OUTPUT
echo "${REPO}:${VERSION_TAG}" >> $GITHUB_OUTPUT
echo "${REPO}:latest" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
PR_NUMBER=${{ github.event.pull_request.number }}
echo "tags=${REPO}:pr-${PR_NUMBER}" >> $GITHUB_OUTPUT
else
echo "tags=${REPO}:dev" >> $GITHUB_OUTPUT
fi
- name: Build and push multi-platform image
uses: docker/build-push-action@v7
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
provenance: false
cache-from: type=gha
cache-to: type=gha,mode=max