Skip to content

Commit 37642a1

Browse files
committed
[NEW] Github Actions
1 parent f83e474 commit 37642a1

File tree

6 files changed

+86
-1011
lines changed

6 files changed

+86
-1011
lines changed

.github/workflows/ci-cd.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Docker CI/CD
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
API_IMAGE_NAME: github-api
11+
API_CONTAINER_NAME: github-api
12+
UI_IMAGE_NAME: github-ui
13+
UI_CONTAINER_NAME: github-ui
14+
15+
REPO_NAME: ${{ github.repository }}
16+
REGISTRY: ghcr.io
17+
18+
jobs:
19+
build_and_push:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
packages: write
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v3
27+
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
- name: Log in to the Container registry
32+
uses: docker/login-action@v3
33+
with:
34+
registry: ${{ env.REGISTRY }}
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Build and push API Docker image
39+
uses: docker/build-push-action@v5
40+
with:
41+
context: .
42+
file: ./API.Dockerfile
43+
push: true
44+
tags: ${{ env.REGISTRY }}/${{ env.REPO_NAME}}/${{ env.API_IMAGE_NAME }}:${{ github.sha }}
45+
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_NAME}}/${{ env.API_IMAGE_NAME }}:buildcache
46+
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_NAME}}/${{ env.API_IMAGE_NAME }}:buildcache,mode=max
47+
48+
- name: Build and push UI Docker image
49+
uses: docker/build-push-action@v5
50+
with:
51+
context: .
52+
file: ./UI.Dockerfile
53+
push: true
54+
tags: ${{ env.REGISTRY }}/${{ env.REPO_NAME}}/${{ env.UI_IMAGE_NAME }}:${{ github.sha }}
55+
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_NAME}}/${{ env.UI_IMAGE_NAME }}:buildcache
56+
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_NAME}}/${{ env.UI_IMAGE_NAME }}:buildcache,mode=max
57+

0 commit comments

Comments
 (0)