This repository has been archived by the owner on Feb 18, 2025. It is now read-only.
fix: argocd authentication error (#90) #123
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: | |
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 |