Skip to content

Commit 95298b9

Browse files
authored
add github action: release.yml
1 parent 09929d7 commit 95298b9

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Release and Publish Image (inspired by ZPI github action)
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
env:
9+
REGISTRY: "ghcr.io"
10+
IMAGE_NAME: ${{ github.repository }}
11+
12+
jobs:
13+
build-and-push-image:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: "read"
17+
packages: "write"
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Log in to the GitHub Container Registry
24+
uses: docker/login-action@v3
25+
with:
26+
registry: ${{ env.REGISTRY }}
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Make metadata
31+
id: meta
32+
uses: docker/metadata-action@v5
33+
with:
34+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
35+
tags: |
36+
type=semver,pattern={{version}}
37+
type=raw,value=latest,enable={{is_default_branch}}
38+
39+
- name: Set up Docker Buildx
40+
uses: docker/setup-buildx-action@v3
41+
42+
- name: Push image
43+
uses: docker/build-push-action@v6
44+
with:
45+
context: .
46+
push: true
47+
tags: ${{ steps.meta.outputs.tags }}
48+
labels: ${{ steps.meta.outputs.labels }}
49+
cache-from: type=gha
50+
cache-to: type=gha,mode=max
51+
52+

0 commit comments

Comments
 (0)