Skip to content

Update dp.yml

Update dp.yml #44

Workflow file for this run

name: Deploy to Kubernetes
on:
push:
branches:
- main
- kustomize
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
EKS_CLUSTER_NAME: ${{ secrets.EKS_CLUSTER_NAME }}
OIDC_ROLE_ARN: ${{ secrets.OIDC_ROLE }}
WEBHOOK_URL: ${{ secrets.WEBHOOK }}
ARGOCD_AUTH_TOKEN: ${{ secrets.ARGOCD_AUTH_TOKEN }}
KUSTOMIZE_REPO: "Project-Catcher/catcher-service-kusto"
DEPLOY_ENV: ${{ github.ref == 'refs/heads/main' && 'PROD' || 'DEV' }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
pages: write
id-token: write
jobs:
deploy:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ env.AWS_REGION }}
role-session-name: GitHubActions
role-to-assume: ${{ env.OIDC_ROLE_ARN }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
# kustomize 명령을 가져온다.
- name: Setup Kustomize
uses: imranismail/setup-kustomize@v1
- name: Checkout for Kustomize repository
uses: actions/checkout@v2
with:
repository: ${{ env.KUSTOMIZE_REPO }}
ref: main
token: ${{ env.GITHUB_TOKEN }}
path: catcher-service-kusto
- name: Update Kustomize image
run: |
if [ "${{ env.DEPLOY_ENV }}" == "PROD" ]; then
KUSTOMIZE_PATH="catcher-service-kusto/k8s/overlays/production"
FILE_NAME="production-patch.yaml"
else
KUSTOMIZE_PATH="catcher-service-kusto/k8s/overlays/development"
FILE_NAME="deployment-patch.yaml"
fi
# Docker 이미지 URL 설정
cd $KUSTOMIZE_PATH
kustomize edit set image catcher-service="${{ steps.login-ecr.outputs.registry }}:catcher-service"
cat kustomization.yaml
# 수정된 파일 commit & push
- name: Commit files
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
run: |
cd catcher-service-kusto
pwd
git config --global user.email "[email protected]"
git config --global user.name "Taein2"
git remote set-url origin https://${{ github.actor }}:${{ env.GITHUB_TOKEN }}@github.com/Project-Catcher/catcher-service-kusto.git
git commit -am "Update image tag ${{ steps.tag_version.outputs.new_tag }}"
git push -u origin main
- name: Send Notification
if: ${{ always() }}
run: |
if [[ ${{ job.status }} == "success" ]]; then
MESSAGE="🏷 ${{ job.status }} Kustomize Update 성공: Catcher-service - by ${{ github.actor }}"
else
MESSAGE="❌ ${{ job.status }} Kustomize Update 실패: Catcher-service - by ${{ github.actor }}"
fi
curl -X POST -H "Content-Type: application/json" --data "{\"text\":\"${MESSAGE}\"}" ${{ env.WEBHOOK_URL }}