-
Notifications
You must be signed in to change notification settings - Fork 1
Update a variables and notification emoji #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Taein2
wants to merge
3
commits into
dev
Choose a base branch
from
githubaction
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
name: Deploy to Kubernetes | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Java CI with Gradle"] | ||
branches: [main] | ||
types: | ||
- completed | ||
|
||
push: | ||
branches: | ||
- kustomize | ||
|
||
env: | ||
AWS_REGION: ${{ secrets.AWS_REGION }} | ||
EKS_CLUSTER_NAME: ${{ secrets.EKS_CLUSTER_NAME }} | ||
OIDC_ROLE_ARN: ${{ secrets.OIDC_ROLE }} | ||
WEBHOOK_URL: ${{ secrets.WEBHOOK }} | ||
DEPLOY_ENV: ${{ github.ref == 'refs/heads/main' && 'PROD' || 'DEV' }} | ||
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }} | ||
|
||
permissions: | ||
contents: write | ||
id-token: write | ||
|
||
jobs: | ||
kustomize_upadte: | ||
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: Project-Catcher/core-service-kusto | ||
ref: main | ||
token: ${{ env.GITHUB_TOKEN }} | ||
path: core-service-kusto | ||
|
||
- name: Update Kustomize image | ||
run: | | ||
if [ "${{ env.DEPLOY_ENV }}" == "PROD" ]; then | ||
KUSTOMIZE_PATH="core-service-kusto/overlays/production" | ||
FILE_NAME="production-patch.yaml" | ||
else | ||
KUSTOMIZE_PATH="core-service-kusto/overlays/development" | ||
FILE_NAME="deployment-patch.yaml" | ||
fi | ||
|
||
# Docker 이미지 URL 설정 | ||
cd $KUSTOMIZE_PATH | ||
kustomize edit set image core-service="${{ steps.login-ecr.outputs.registry }}/catcher-dev-ecr-back-core:${{ github.sha }}" | ||
cat kustomization.yaml | ||
|
||
- name: Check for changes | ||
id: git-check | ||
run: | | ||
cd core-service-kusto | ||
git status | ||
git diff-index --quiet HEAD || echo "::set-output name=changes_exist::true" | ||
|
||
# 수정된 파일 commit & push | ||
- name: Commit manifest files | ||
if: steps.git-check.outputs.changes_exist == 'true' | ||
run: | | ||
cd core-service-kusto | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "github-actions" | ||
git commit -am "Update image tag" | ||
git push -u origin main | ||
|
||
- name: Send Notification | ||
if: ${{ always() }} | ||
run: | | ||
if [[ '${{ steps.git-check.outputs.changes_exist }}' == 'true' && ${{ job.status }} == 'success' ]]; then | ||
MESSAGE="✅ ${{ job.status }} Kustomize Update 성공: core-service-kusto - by ${{ github.actor }}" | ||
elif [[ '${{ steps.git-check.outputs.changes_exist }}' != 'true' && ${{ job.status }} == 'success' ]]; then | ||
MESSAGE="ℹ️ ${{ job.status }} Kustomize : 수정 사항 없음 - core-service-kusto - by ${{ github.actor }}" | ||
else | ||
MESSAGE="❌ ${{ job.status }} Kustomize Update 실패: core-service-kusto - by ${{ github.actor }}" | ||
fi | ||
curl -X POST -H "Content-Type: application/json" --data "{\"text\":\"${MESSAGE}\"}" ${{ env.WEBHOOK_URL }} | ||
Taein2 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,26 +5,29 @@ on: | |
branches: [ "main" ] | ||
|
||
env: | ||
ECR_URL: ${{ secrets.ECR_REPO_DEV }} | ||
ROLE_ARN: ${{ secrets.OIDC_ROLE }} | ||
AWS_REGION: ${{ secrets.AWS_REGION }} | ||
OIDC_ROLE_ARN: ${{ secrets.OIDC_ROLE }} | ||
DEPLOY_ENV: ${{ github.ref == 'refs/heads/main' && 'PROD' || 'DEV' }} | ||
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }} | ||
ECR_URL: ${{ secrets.AWS_ECR_DEV_CORE }} | ||
webhook_url: ${{ secrets.WEBHOOK }} | ||
WEBHOOK_URL: ${{ secrets.WEBHOOK }} | ||
|
||
permissions: | ||
id-token: write | ||
contents: write | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
# runs-on: self-hosted | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
id-token: write # This is required for requesting the JWT | ||
contents: read # This is required for actions/checkout | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
|
@@ -47,52 +50,25 @@ jobs: | |
with: | ||
aws-region: ${{ env.AWS_REGION }} | ||
role-session-name: GitHubActions | ||
role-to-assume: ${{ env.OIDC_ROLE_ARN }} | ||
role-to-assume: ${{ env.ROLE_ARN }} | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Publish Image to ECR(CORE-SERVICE) | ||
- name: Publish Image to ECR(core-SERVICE) | ||
run: | | ||
docker tag core-service:latest ${{ env.ECR_URL }}:${{ github.sha }} | ||
docker push ${{ env.ECR_URL }}:${{ github.sha }} | ||
|
||
- name: notification to swit | ||
uses: roharon/action-swit@v1 | ||
with: | ||
webhooks_url: ${{ env.webhook_url }} | ||
MESSAGE: "🏷 ${{ job.status }} 백엔드 ECR 도커파일 업로드 : Core-service - by ${{ github.actor }}" | ||
docker tag core-service:latest ${{ env.ECR_URL }}:core-service | ||
docker push ${{ env.ECR_URL }}:core-service | ||
|
||
- name: Setup Kustomize | ||
uses: imranismail/setup-kustomize@v1 | ||
|
||
- name: Checkout for Kustomize repository | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: Project-Catcher/core-service-kusto | ||
ref: main | ||
token: ${{ env.GITHUB_TOKEN }} | ||
path: core-service-kusto | ||
|
||
- name: Update Kustomize image | ||
- name: Send Notification | ||
if: ${{ always() }} | ||
run: | | ||
# PRD/DEV 브랜치 분리되어있지 않으므로 추후 업데이트 예정 | ||
# if [ "${{ env.DEPLOY_ENV }}" == "PROD" ]; then | ||
# KUSTOMIZE_PATH="core-service-kusto/overlays/prd" | ||
# else | ||
# KUSTOMIZE_PATH="core-service-kusto/overlays/dev" | ||
# fi | ||
if [[ ${{ job.status }} == "success" ]]; then | ||
MESSAGE="✅ ${{ job.status }} 백엔드 ECR 도커파일 업로드 성공: core-service - by ${{ github.actor }}" | ||
else | ||
MESSAGE="❌ ${{ job.status }} 백엔드 ECR 도커파일 업로드 실패: core-service - by ${{ github.actor }}" | ||
fi | ||
curl -X POST -H "Content-Type: application/json" --data "{\"text\":\"${MESSAGE}\"}" ${{ env.WEBHOOK_URL }} | ||
|
||
KUSTOMIZE_PATH="core-service-kusto/overlays/dev" | ||
cd $KUSTOMIZE_PATH | ||
kustomize edit set image core-svc-image="${{ env.ECR_URL }}:${{ github.sha }}" | ||
kustomize build . | ||
|
||
- name: Commit minifest files | ||
run: | | ||
cd core-service-kusto | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "github-actions" | ||
git commit -am "Update image tag" | ||
git push -u origin main | ||
|
||
Taein2 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.