Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit a214a40

Browse files
committed
feat: Add ghcr.io container builds
1 parent 896bc86 commit a214a40

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

Diff for: .github/workflows/publish-image.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
name: Docker image
3+
4+
on: push
5+
6+
env:
7+
REGISTRY: ghcr.io
8+
IMAGE_NAME: ${{ github.repository }}
9+
10+
jobs:
11+
build-and-push-image:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Get the release channel
22+
id: get_channel
23+
shell: bash
24+
run: |
25+
if [[ "$GITHUB_REF" == 'refs/heads/main' ]]; then
26+
echo "channel=latest" >> $GITHUB_OUTPUT
27+
echo "version=main_${GITHUB_SHA::6}" >> $GITHUB_OUTPUT
28+
elif [[ "$GITHUB_REF" == "refs/heads/"* ]]; then
29+
echo "version=${GITHUB_REF/refs\/heads\//}_${GITHUB_SHA::6}" >> $GITHUB_OUTPUT
30+
elif [[ "$GITHUB_REF" == "refs/tags/"* ]]; then
31+
echo "channel=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
32+
fi
33+
34+
- name: Extract metadata (tags, labels) for Docker
35+
id: meta
36+
uses: docker/metadata-action@v4
37+
with:
38+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
39+
tags: |
40+
type=raw,value=${{ steps.get_channel.outputs.channel }}
41+
type=raw,value=${{ steps.get_channel.outputs.version }}
42+
43+
- name: Log in to the Container registry
44+
uses: docker/login-action@v2
45+
with:
46+
registry: ${{ env.REGISTRY }}
47+
username: ${{ github.actor }}
48+
password: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Build and push Docker image
51+
uses: docker/build-push-action@v4
52+
with:
53+
context: .
54+
push: true
55+
tags: ${{ steps.meta.outputs.tags }}
56+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)