Skip to content

Commit c6a5a18

Browse files
authored
ci: add GitHub Actions workflow for ArgoCD deployment
1 parent 1d17eb4 commit c6a5a18

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

.github/workflows/deploy_argo.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Deploy Go to ArgoCD (manual)
2+
3+
on:
4+
workflow_dispatch: # ← Manual trigger button
5+
inputs:
6+
version:
7+
description: 'version'
8+
required: false
9+
default: 'latest'
10+
type: string
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
env:
16+
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
17+
steps:
18+
- name: checkout
19+
uses: actions/checkout@v4
20+
- name: login to dockerhub
21+
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1
22+
with:
23+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
24+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
25+
- name: build docker image
26+
run: |
27+
docker build -t "${DOCKER_HUB_USERNAME}/ceramicraft-user-mservice:${{ github.event.inputs.version }}" server/
28+
- name: push to dockerhub
29+
run: |
30+
docker push "${DOCKER_HUB_USERNAME}/ceramicraft-user-mservice:${{ github.event.inputs.version }}"
31+
update-argocd:
32+
needs: build
33+
runs-on: ubuntu-latest
34+
permissions:
35+
contents: write
36+
steps:
37+
- name: Checkout argocd deploy repo
38+
uses: actions/checkout@v4
39+
with:
40+
repository: NUS-ISS-Agile-Team/ceramicraft-argocd-deploy
41+
token: ${{ secrets.PAT_TOKEN }}
42+
ref: main
43+
path: argocd-deploy
44+
- name: Update values.yaml tag
45+
run: |
46+
cd argocd-deploy/helm_backend/user-ms
47+
TAG="${{ github.event.inputs.version }}"
48+
sed -i.bak "5s|^.*$| tag: ${TAG}|" values.yaml
49+
rm -f values.yaml.bak
50+
- name: Commit and push changes
51+
env:
52+
GIT_AUTHOR_NAME: github-actions[bot]
53+
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
54+
GIT_COMMITTER_NAME: github-actions[bot]
55+
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
56+
run: |
57+
cd argocd-deploy
58+
git config user.name "${GIT_AUTHOR_NAME}"
59+
git config user.email "${GIT_AUTHOR_EMAIL}"
60+
git add helm_backend/user-ms/values.yaml
61+
git commit -m "chore(user-ms): bump tag to ${{ github.event.inputs.version }} [skip ci]" || echo "No changes to commit"
62+
git push origin HEAD:main

0 commit comments

Comments
 (0)