Skip to content

Commit 551b01b

Browse files
committed
feat(infra): add GitHub workflows for CI/CD
1 parent bc5ae7b commit 551b01b

File tree

2 files changed

+34
-25
lines changed

2 files changed

+34
-25
lines changed

.github/workflows/build-push.yml

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,41 @@
11
name: Build and Push to GHCR
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
- develop
4+
workflow_run:
5+
workflows: ["Run Tests"]
6+
types:
7+
- completed
8+
branches: [ main, develop ]
9+
810

911
jobs:
1012
build-push:
1113
runs-on: ubuntu-latest
12-
14+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
15+
1316
steps:
14-
- name: Checkout code
15-
uses: actions/checkout@v3
16-
17-
- name: Login to GitHub Container Registry
18-
uses: docker/login-action@v2
19-
with:
20-
registry: ghcr.io
21-
username: ${{ github.actor }}
22-
password: ${{ secrets.GITHUB_TOKEN }}
23-
24-
- name: Build and push Docker image
25-
uses: docker/build-push-action@v4
26-
with:
27-
context: .
28-
file: memory-infra/docker/Dockerfile
29-
push: true
30-
tags: |
31-
ghcr.io/${{ github.repository }}/memory-app:${{ github.sha }}
32-
${{ github.ref == 'refs/heads/main' && format('ghcr.io/{0}/memory-app:latest', github.repository) || format('ghcr.io/{0}/memory-app:dev', github.repository) }}
17+
- name: Checkout code
18+
uses: actions/checkout@v3
19+
20+
- name: Login to GitHub Container Registry
21+
uses: docker/login-action@v2
22+
with:
23+
registry: ghcr.io
24+
username: ${{ github.actor }}
25+
password: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Convert to lowercase
28+
id: string
29+
uses: ASzc/change-string-case-action@v5
30+
with:
31+
string: ${{ github.repository }}
32+
33+
- name: Build and push Docker image
34+
uses: docker/build-push-action@v4
35+
with:
36+
context: .
37+
file: memory-infra/docker/Dockerfile
38+
push: true
39+
tags: |
40+
ghcr.io/${{ steps.string.outputs.lowercase }}/memory-app:${{ github.sha }}
41+
${{ github.ref == 'refs/heads/main' && format('ghcr.io/{0}/memory-app:latest', steps.string.outputs.lowercase) || format('ghcr.io/{0}/memory-app:dev', steps.string.outputs.lowercase) }}

.github/workflows/deploy-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Deploy to Development Server
22

33
on:
44
workflow_run:
5-
workflows: ["Run Tests", "Build and Push to GHCR"]
5+
workflows: ["Build and Push to GHCR"]
66
types:
77
- completed
88
branches: [ develop ]

0 commit comments

Comments
 (0)