Skip to content

Commit 09bec5a

Browse files
committed
Add workflow to build container image
1 parent 2e32014 commit 09bec5a

2 files changed

Lines changed: 70 additions & 0 deletions

File tree

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.git
2+
.github
3+
node_modules
4+
npm-debug.log*
5+
test-results
6+
traces-*.json
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Publish container image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "v*.*.*"
9+
pull_request:
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
env:
17+
REGISTRY: ghcr.io
18+
19+
jobs:
20+
image:
21+
name: Build container image
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Check out repository
26+
uses: actions/checkout@v4
27+
28+
- name: Resolve image name
29+
id: image
30+
run: echo "name=${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
31+
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v3
34+
35+
- name: Log in to GitHub Container Registry
36+
if: github.event_name != 'pull_request'
37+
uses: docker/login-action@v3
38+
with:
39+
registry: ${{ env.REGISTRY }}
40+
username: ${{ github.actor }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Extract image metadata
44+
id: meta
45+
uses: docker/metadata-action@v5
46+
with:
47+
images: ${{ env.REGISTRY }}/${{ steps.image.outputs.name }}
48+
tags: |
49+
type=ref,event=branch
50+
type=ref,event=pr
51+
type=ref,event=tag
52+
type=sha,prefix=sha-
53+
type=raw,value=latest,enable={{is_default_branch}}
54+
55+
- name: Build and publish image
56+
uses: docker/build-push-action@v6
57+
with:
58+
context: .
59+
file: ./Dockerfile
60+
push: ${{ github.event_name != 'pull_request' }}
61+
tags: ${{ steps.meta.outputs.tags }}
62+
labels: ${{ steps.meta.outputs.labels }}
63+
cache-from: type=gha
64+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)