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

Commit 4745578

Browse files
committed
feat: add docker workflow
1 parent 0dcdf60 commit 4745578

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Docker_build_push
2+
3+
on:
4+
push:
5+
branches: [develop]
6+
pull_request:
7+
branches: [develop]
8+
release:
9+
types: [created]
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
jobs:
16+
docker:
17+
name: Build and push docker image to GitHub Container Registry
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v2
25+
26+
- name: Inject slug/short variables
27+
uses: rlespinasse/github-slug-action@v4
28+
with:
29+
short-length: 7
30+
31+
- name: Login to GitHub Container Registry
32+
uses: docker/login-action@v2
33+
with:
34+
registry: ${{ env.REGISTRY }}
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Extract metadata (tags, labels) for Docker
39+
id: meta
40+
uses: docker/metadata-action@v4
41+
with:
42+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
43+
tags: |
44+
type=ref,event=branch
45+
type=ref,event=pr
46+
type=raw,value=test,enable={{is_default_branch}}
47+
type=semver,pattern={{version}}
48+
type=semver,pattern={{major}}.{{minor}}
49+
50+
- name: Push to GitHub Container Registry
51+
uses: docker/build-push-action@v3
52+
with:
53+
context: .
54+
push: true
55+
platforms: linux/amd64,linux/arm64
56+
file: ./Dockerfile
57+
tags: ${{ steps.meta.outputs.tags }}
58+
labels: ${{ steps.meta.outputs.labels }}
59+
cache-from: |
60+
type=registry,ref=ghcr.io/${{ github.repository }}:build-cache-${{ env.GITHUB_REF_SLUG_URL }}-${{ github.workflow }}
61+
type=registry,ref=ghcr.io/${{ github.repository }}:build-cache-develop-${{ github.workflow }}
62+
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}:build-cache-${{ env.GITHUB_REF_SLUG_URL }}-${{ github.workflow }},mode=max

0 commit comments

Comments
 (0)