Skip to content

Commit 8937f79

Browse files
committed
Added github actions
1 parent 750c949 commit 8937f79

5 files changed

Lines changed: 267 additions & 150 deletions

File tree

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Release Multi-Arch Images
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: "Release tag to publish (for example: v1.2.3)"
11+
required: false
12+
type: string
13+
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
jobs:
19+
resolve:
20+
name: Resolve Release Context
21+
runs-on: ubuntu-latest
22+
outputs:
23+
release_tag: ${{ steps.vars.outputs.release_tag }}
24+
image_base: ${{ steps.vars.outputs.image_base }}
25+
steps:
26+
- name: Resolve tag and image base
27+
id: vars
28+
shell: bash
29+
run: |
30+
set -euo pipefail
31+
32+
repo_lc="$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')"
33+
echo "image_base=ghcr.io/${repo_lc}" >> "$GITHUB_OUTPUT"
34+
35+
if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
36+
tag="${GITHUB_REF_NAME}"
37+
else
38+
tag="${{ github.event.inputs.tag }}"
39+
if [[ -z "$tag" && "${GITHUB_REF_TYPE}" == "tag" ]]; then
40+
tag="${GITHUB_REF_NAME}"
41+
fi
42+
fi
43+
44+
if [[ ! "$tag" =~ ^v.+$ ]]; then
45+
echo "Workflow requires a tag in v* format."
46+
echo "Provide workflow_dispatch input 'tag' or run from a v* tag ref."
47+
exit 1
48+
fi
49+
50+
echo "release_tag=${tag}" >> "$GITHUB_OUTPUT"
51+
52+
backend:
53+
name: Build Backend Image
54+
runs-on: ubuntu-latest
55+
needs: resolve
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v4
59+
with:
60+
ref: ${{ needs.resolve.outputs.release_tag }}
61+
62+
- name: Set up QEMU
63+
uses: docker/setup-qemu-action@v3
64+
65+
- name: Set up Docker Buildx
66+
uses: docker/setup-buildx-action@v3
67+
68+
- name: Log in to GHCR
69+
uses: docker/login-action@v3
70+
with:
71+
registry: ghcr.io
72+
username: ${{ github.actor }}
73+
password: ${{ secrets.GITHUB_TOKEN }}
74+
75+
- name: Build and push backend
76+
uses: docker/build-push-action@v6
77+
with:
78+
context: .
79+
file: backend/Dockerfile
80+
platforms: linux/amd64,linux/arm64
81+
push: true
82+
tags: |
83+
${{ needs.resolve.outputs.image_base }}-backend:${{ needs.resolve.outputs.release_tag }}
84+
${{ needs.resolve.outputs.image_base }}-backend:latest
85+
86+
frontend:
87+
name: Build Frontend Image
88+
runs-on: ubuntu-latest
89+
needs: resolve
90+
steps:
91+
- name: Checkout
92+
uses: actions/checkout@v4
93+
with:
94+
ref: ${{ needs.resolve.outputs.release_tag }}
95+
96+
- name: Set up QEMU
97+
uses: docker/setup-qemu-action@v3
98+
99+
- name: Set up Docker Buildx
100+
uses: docker/setup-buildx-action@v3
101+
102+
- name: Log in to GHCR
103+
uses: docker/login-action@v3
104+
with:
105+
registry: ghcr.io
106+
username: ${{ github.actor }}
107+
password: ${{ secrets.GITHUB_TOKEN }}
108+
109+
- name: Build and push frontend
110+
uses: docker/build-push-action@v6
111+
with:
112+
context: frontend
113+
file: frontend/Dockerfile
114+
platforms: linux/amd64,linux/arm64
115+
push: true
116+
tags: |
117+
${{ needs.resolve.outputs.image_base }}-frontend:${{ needs.resolve.outputs.release_tag }}
118+
${{ needs.resolve.outputs.image_base }}-frontend:latest

0 commit comments

Comments
 (0)