Skip to content

Commit f145494

Browse files
authored
chore: support to release docker image (#14)
Co-authored-by: rick <LinuxSuRen@users.noreply.github.com>
1 parent 7b9577d commit f145494

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

.github/workflows/release.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
branches:
8+
- master
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
image:
16+
runs-on: ubuntu-20.04
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-tags: true
22+
fetch-depth: 0
23+
- name: Set output
24+
id: vars
25+
run: echo "tag=$(git describe --tags)" >> $GITHUB_OUTPUT
26+
- name: Setup Docker buildx
27+
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
28+
- name: Log into registry ${{ env.REGISTRY }}
29+
if: github.event_name != 'pull_request'
30+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GH_PUBLISH_SECRETS }}
35+
- name: Extract Docker metadata
36+
id: meta
37+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
38+
with:
39+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
40+
- name: Build and push Docker image
41+
id: build-and-push
42+
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
43+
with:
44+
context: .
45+
push: ${{ github.event_name != 'pull_request' }}
46+
tags: ${{ steps.meta.outputs.tags }}
47+
labels: ${{ steps.meta.outputs.labels }}
48+
platforms: linux/amd64
49+
cache-from: type=gha
50+
cache-to: type=gha,mode=max
51+
build-args: VERSION=${{ steps.vars.outputs.tag }}

0 commit comments

Comments
 (0)