-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (92 loc) · 3.17 KB
/
release-docker.yml
File metadata and controls
105 lines (92 loc) · 3.17 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
name: Release Docker Images
on:
workflow_dispatch:
push:
tags:
- 'v*'
permissions:
contents: read
packages: write
env:
DOCKERHUB_NAMESPACE: interaapps
concurrency:
group: release-docker-${{ github.ref }}
cancel-in-progress: false
jobs:
publish-images:
name: Publish ${{ matrix.image_name }} image
runs-on: ubuntu-latest
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKER_PASSWORD }}
strategy:
fail-fast: false
matrix:
include:
- image_name: backend
dockerfile: Dockerfile.backend
- image_name: frontend
dockerfile: Dockerfile.frontend
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
if: env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != ''
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_TOKEN }}
- name: Compute image names
id: image
shell: bash
run: |
repository="$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')"
ghcr_image="ghcr.io/${repository}-${{ matrix.image_name }}"
echo "repository=${repository}" >> "${GITHUB_OUTPUT}"
if [ "${{ matrix.image_name }}" = "backend" ]; then
dockerhub_image="docker.io/${DOCKERHUB_NAMESPACE}/starquery"
else
dockerhub_image="docker.io/${DOCKERHUB_NAMESPACE}/starquery-${{ matrix.image_name }}"
fi
echo "ghcr_image=${ghcr_image}" >> "${GITHUB_OUTPUT}"
echo "dockerhub_image=${dockerhub_image}" >> "${GITHUB_OUTPUT}"
{
echo "images<<EOF"
echo "${ghcr_image}"
if [ -n "${DOCKERHUB_USERNAME}" ] && [ -n "${DOCKERHUB_TOKEN}" ]; then
echo "${dockerhub_image}"
fi
echo "EOF"
} >> "${GITHUB_OUTPUT}"
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.image.outputs.images }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=ref,event=tag
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=sha,prefix=sha-
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.image_name }}
cache-to: type=gha,scope=${{ matrix.image_name }},mode=max