Skip to content

Commit 8228c88

Browse files
committed
[ci]: add workflow to build and push new images to registry
Summary: This workflow build the docker images for the reader and writer applications and pushes the images to dockerhub. It also changes the image versions referenced in the kustomation.yaml file to match the new one's built ( using the git commit SHA as the tag) and pushes the changes to this repo. ArgoCD is setup to keep an eye on this repo and sync any changes in the cluster.
1 parent da9b27c commit 8228c88

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build and publish application
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- ".github/workflows/**"
9+
- "0x3-logger/**"
10+
11+
env:
12+
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
13+
DOCKER_PAT: ${{ secrets.DOCKERHUB_TOKEN }}
14+
15+
jobs:
16+
build-publish:
17+
if: github.event.ref_type == 'branch'
18+
name: Build, Push, Release
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout Code
23+
uses: actions/checkout@v4
24+
25+
- name: Login to Docker Hub
26+
uses: docker/login-action@v3
27+
with:
28+
username: "${{ env.DOCKER_USERNAME}}"
29+
password: "${{ secrets.DOCKER_PAT }}"
30+
31+
- name: Build and Publish 'reader' image
32+
working-directory: 0x3-logger/reader
33+
run: |-
34+
docker build --tag "akhonya/reader:$GITHUB_SHA" .
35+
docker push "akhonya/reader:$GITHUB_SHA"
36+
37+
- name: Build and Publish 'writter' image
38+
working-directory: 0x3-logger/writter
39+
run: |-
40+
docker build --tag "akhonya/reader:$GITHUB_SHA" .
41+
docker push "akhonya/writter:$GITHUB_SHA"
42+
43+
- name: Set up Kustomize
44+
uses: imranismail/setup-kustomize@v2
45+
46+
- name: Use right image
47+
working-directory: "0x3-logger/k8s"
48+
run: |
49+
kustomize edit set image PROJECT/READER=akhonya/reader:$GITHUB_SHA
50+
kustomize edit set image PROJECT/WRITTER=akhonya/writter:$GITHUB_SHA
51+
52+
- name: commit kustomization.yaml to GitHub
53+
uses: EndBug/add-and-commit@v9
54+
with:
55+
add: "0x3-logger/k8s/kustomization.yaml"
56+
message: "[chore]: release new version of app - ${{ github.sha }}"

0 commit comments

Comments
 (0)