From 5a6d1c1fa406909e3a82b8ad72aa2696b582dd77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=A1=EC=98=81=EB=AF=BC?= Date: Wed, 24 Jul 2024 17:26:24 +0900 Subject: [PATCH] chore: update to argocd cicd --- .github/workflows/deploy-argocd.yaml | 56 ++++++++++++++++++++++++++++ .github/workflows/dev-cicd.yaml | 22 +++++------ 2 files changed, 66 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/deploy-argocd.yaml diff --git a/.github/workflows/deploy-argocd.yaml b/.github/workflows/deploy-argocd.yaml new file mode 100644 index 00000000..9dc785f5 --- /dev/null +++ b/.github/workflows/deploy-argocd.yaml @@ -0,0 +1,56 @@ +name: ArgoCD로 배포하기 +on: + workflow_call: + inputs: + argocd-repo-name: + required: true + type: string + overlay-name: + required: true + type: string + service-name: + required: true + type: string + default-image-name: + required: true + type: string + image-name: + required: true + type: string + environment: + required: true + type: string + image-tag: + required: true + type: string + secrets: + PAT_TOKEN: + required: true + +jobs: + build: + runs-on: [ ubuntu-latest ] + name: ArgoCD로 배포하기 + + environment: ${{ inputs.environment }} + + steps: + - name: GitHub 에서 레포 받아오기 + uses: actions/checkout@v3 + with: + repository: ${{ inputs.argocd-repo-name }} + token: ${{ secrets.PAT_TOKEN }} + + - name: Kustomize 설정하기 + uses: imranismail/setup-kustomize@v2 + + - name: 이미지 태그 변경 후 배포하기 + run: | + cd modules/${{ inputs.service-name }}/overlays/${{ inputs.overlay-name }} + kustomize edit set image ${{ inputs.default-image-name }}=${{ inputs.image-name }}:${{ inputs.image-tag }} + cat kustomization.yaml + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git commit -am "release(${{ inputs.service-name }}): 자동배포 ${{ inputs.image-name }}:${{ inputs.image-tag }}" + git config pull.rebase true + git pull && git push -u origin main diff --git a/.github/workflows/dev-cicd.yaml b/.github/workflows/dev-cicd.yaml index bef3f0cd..68290856 100644 --- a/.github/workflows/dev-cicd.yaml +++ b/.github/workflows/dev-cicd.yaml @@ -69,19 +69,17 @@ jobs: call-deploy-workflow: if: github.event_name == 'push' needs: [ prepare-variables, call-build-workflow ] - name: AWS ECS 배포 - uses: ./.github/workflows/deploy-ecs.yaml + name: ArgoCD로 배포하기 + uses: ./.github/workflows/deploy-argocd.yaml permissions: - id-token: write - contents: read + contents: write with: + argocd-repo-name: bibbi-team/bibbi-argocd-manifest + overlay-name: ${{ needs.prepare-variables.outputs.spring-profile }} + service-name: bibbi-backend-api + image-name: bibbi-backend-api-dev + image-tag: ${{ needs.prepare-variables.outputs.image-tag }} environment: development - ecs-service: ${{ needs.prepare-variables.outputs.ecs-service }} - ecs-cluster: ${{ needs.prepare-variables.outputs.ecs-cluster }} - ecr-task-definition: ${{ needs.prepare-variables.outputs.ecr-task-definition }} - image-url: ${{ needs.call-build-workflow.outputs.image-url }} + default-image-name: no5ing/bibbi-backend-api secrets: - AWS_ASSUME_ROLE_ARN: ${{ secrets.AWS_ASSUME_ROLE_ARN }} - AWS_ECR_REGISTRY_URL: ${{ secrets.AWS_ECR_REGISTRY_URL }} - AWS_REGION: ${{ secrets.AWS_REGION }} - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + PAT_TOKEN: ${{ secrets.PAT_TOKEN }}