Skip to content

Commit d0f6d80

Browse files
committed
Merge branch 'main' of github.com:Code4GovTech/DMP-CMS-Backend-API into dev
2 parents 4ba4f74 + 53c9a68 commit d0f6d80

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

.github/workflows/build-and-bush.yaml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
release:
9+
types: [published]
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
build-and-push:
16+
runs-on: ubuntu-latest
17+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
18+
permissions:
19+
contents: read
20+
packages: write
21+
steps:
22+
23+
- name: Checkout code
24+
uses: actions/checkout@v2
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v2
28+
29+
- name: Log in to the Container registry
30+
uses: docker/login-action@v3
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Extract metadata (tags, labels) for Docker
37+
id: meta
38+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
39+
with:
40+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41+
tags: |
42+
# minimal
43+
type=pep440,pattern={{version}},value=${{ github.ref_name }},enable=${{ github.event_name == 'release' }}
44+
# branch event
45+
type=ref,event=branch
46+
type=raw,value=latest,enable=${{ github.event_name == 'release' }}
47+
48+
- name: Build and Push Docker image
49+
uses: docker/build-push-action@v4
50+
with:
51+
# build-args:
52+
context: .
53+
push: true
54+
cache-from: type=gha
55+
cache-to: type=gha,mode=max
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)