This repository has been archived by the owner on Feb 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (94 loc) · 2.83 KB
/
gitops.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: GitOps
on:
push:
branches:
- main
- staging
paths:
- services/**
workflow_dispatch:
permissions:
contents: write
jobs:
changes:
runs-on: ubuntu-latest
outputs:
services: ${{ steps.filter.outputs.changes }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Filter file changes
id: filter
uses: dorny/paths-filter@v3
with:
base: ${{ github.ref }}
filters: |
web:
- 'services/web/**'
account:
- 'services/account/**'
item:
- 'services/item/**'
wishlist:
- 'services/wishlist/**'
transaction:
- 'services/transaction/**'
notification:
- 'services/notification/**'
rabbitmq:
- 'services/rabbitmq/**'
build:
name: Build and push Docker image
runs-on: ubuntu-latest
needs: changes
strategy:
matrix:
service: ${{ fromJson(needs.changes.outputs.services) }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./services/${{ matrix.service }}
push: true
tags: |
z1yoon/nshm-${{ matrix.service }}:${{ github.ref_name }}-${{ matrix.service }}-${{ github.sha }}
z1yoon/nshm-${{ matrix.service }}:${{ github.ref_name }}
build-args: |
NEXT_PUBLIC_API_BASE_URL=${{ secrets.NEXT_PUBLIC_API_BASE_URL }}
update:
name: Update and Sync Image Tag in ArgoCD
runs-on: ubuntu-latest
container:
image: argoproj/argocd
options: --user root
needs: changes
strategy:
matrix:
service: ${{ fromJson(needs.changes.outputs.services) }}
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Generate New Image Tag
run: |
new_image_tag=${{ matrix.service }}-${{ github.sha }}
echo "new_image_tag=$new_image_tag" >> $GITHUB_ENV
- name: Authenticate to ArgoCD
run: |
argocd login argocd.nshm.store \
--username admin \
--password ${{ secrets.ARGOCD_PASSWORD }} \
--insecure
continue-on-error: true
- name: Update ArgoCD Application with New Image Tag
run: |
argocd app set nshm-$GITHUB_REF_NAME \
--helm-set ${{ matrix.service }}.image.tag=${{ env.new_image_tag }}
argocd app get nshm-$GITHUB_REF_NAME -o yaml
continue-on-error: true