fix: adjust argocd command #118
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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-and-sync: | |
name: Update Helm Manifests | |
runs-on: ubuntu-latest | |
container: | |
image: argoproj/argocd | |
options: --user root | |
needs: changes | |
strategy: | |
matrix: | |
service: ${{ fromJson(needs.changes.outputs.services) }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Update Image Tag Values | |
run: | | |
new_image_tag=${{ matrix.service }}-${{ github.sha }} | |
echo "new_image_tag=$new_image_tag" >> $GITHUB_ENV | |
- name: Login to ArgoCD | |
run: | | |
argocd login argocd.nshm.store \ | |
--username admin \ | |
--password ${{ secrets.ARGOCD_PASSWORD }} \ | |
--insecure | |
- name: Apply Changes with ArgoCD CLI | |
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 |