Skip to content

Commit

Permalink
Merge remote-tracking branch 'Catcher-origin/develop' into feat/makeplan
Browse files Browse the repository at this point in the history
  • Loading branch information
Choi-Jinwook committed Nov 27, 2023
2 parents 5f3fa95 + 667e0db commit 8069dbf
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
name: Check Errors

on:
pull_request:
branches: [ "develop", "main" ]
workflow_call:

jobs:
err_check:
name: Check Errors
# runs-on: self-hosted
runs-on: ubuntu-latest
runs-on: self-hosted

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Set Node.js 16.x
uses: actions/setup-node@v3
- name: Set Node.js 18.18
uses: actions/setup-node@v4
with:
node-version: 18.18
node-version: 18.18

- name: Setup yarn
run: npm install -g yarn
Expand All @@ -35,4 +32,4 @@ jobs:
run: yarn lint

- name: Check tsc-project
run: yarn tsc-project
run: yarn tsc-project
2 changes: 1 addition & 1 deletion .github/workflows/cr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ permissions:

jobs:
code_review:
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- uses: anc95/ChatGPT-CodeReview@main
env:
Expand Down
40 changes: 19 additions & 21 deletions .github/workflows/front.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
name: CI/CD nextjs
name: Build Nextjs

on:
push:
branches: [ "develop", "main" ]

env:
ECR_URL: ${{ secrets.ECR_REPO_DEV_FRONT }}
ROLE_ARN: ${{ secrets.OIDC_ROLE }}
AWS_REGION: ${{ secrets.AWS_REGION }}
WEBHOOK_URL: ${{ secrets.WEBHOOK }}
workflow_call:
secrets:
ECR_REPO_DEV_FRONT:
OIDC_ROLE:
AWS_REGION:
WEBHOOK:
AWS_DEPLOY_APP_NAME:
AWS_DEPLOY_GROUP:
AWS_DEPLOY_CONFIG:

permissions:
id-token: write
contents: read

jobs:
call_err_check:
name: Call workflow Error Check
uses: ./.github/workflows/check_errors.yml
jobs:
build:
name: To push ECR
runs-on: self-hosted
Expand All @@ -31,11 +29,11 @@ jobs:
run: docker build -t catcher-web .

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.AWS_REGION }}
aws-region: ${{ secrets.AWS_REGION }}
role-session-name: GitHubActions
role-to-assume: ${{ env.ROLE_ARN }}
role-to-assume: ${{ secrets.OIDC_ROLE }}

- name: Login to Amazon ECR
id: login-ecr
Expand All @@ -45,23 +43,23 @@ jobs:
run: |
# ECR Front 레포의 기존 이미지 조회
aws ecr describe-images \
--repository-name ${{ secrets.AWS_FRONT_ECR_NAME }} \
--repository-name ${{ secrets.ECR_REPO_DEV_FRONT }} \
--region ${{ secrets.AWS_REGION }} \
--output yaml | grep imageDigest | awk -F ' ' '{print $2}' > ./delete_list.txt
# ECR Front 레포의 기존 이미지 모두 삭제
for front_image in `cat ./delete_list.txt`
do
aws ecr batch-delete-image \
--repository-name ${{ secrets.AWS_FRONT_ECR_NAME }} \
--repository-name ${{ secrets.ECR_REPO_DEV_FRONT }} \
--image-ids imageDigest=$front_image \
--output yaml > /dev/null
done
- name: Publish Image to ECR(CATCHER-WEB)
run: |
docker tag catcher-web:latest ${{ env.ECR_URL }}:${{ github.sha }}
docker push ${{ env.ECR_URL }}:${{ github.sha }}
docker tag catcher-web:latest ${{ secrets.ECR_REPO_DEV_FRONT }}:${{ github.sha }}
docker push ${{ secrets.ECR_REPO_DEV_FRONT }}:${{ github.sha }}
- name: Deploy to Frontend Instance from ECR Image
run: |
Expand All @@ -79,4 +77,4 @@ jobs:
else
MESSAGE="❌ ${{ job.status }} 프론트 배포 실패 : catcher-web - by ${{ github.actor }}"
fi
curl -X POST -H "Content-Type: application/json" --data "{\"text\":\"${MESSAGE}\"}" ${{ env.WEBHOOK_URL }}
curl -X POST -H "Content-Type: application/json" --data "{\"text\":\"${MESSAGE}\"}" ${{ secrets.WEBHOOK }}
46 changes: 46 additions & 0 deletions .github/workflows/on_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: ON PR/Merge - Check Errors | Build

on:
pull_request:
branches: [ "develop", "main" ]
types: [ "opened", "closed" ]
push:
branches: [ "develop", "main" ]

jobs:
merged:
if: ${{ github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true }}
name: Build Nextjs
uses: ./.github/workflows/front.yml
secrets:
ECR_REPO_DEV_FRONT: ${{ secrets.ECR_REPO_DEV_FRONT }}
OIDC_ROLE: ${{ secrets.OIDC_ROLE }}
AWS_REGION: ${{ secrets.AWS_REGION }}
WEBHOOK: ${{ secrets.WEBHOOK }}
AWS_DEPLOY_APP_NAME: ${{ secrets.AWS_DEPLOY_APP_NAME }}
AWS_DEPLOY_GROUP: ${{ secrets.AWS_DEPLOY_GROUP }}
AWS_DEPLOY_CONFIG: ${{ secrets.AWS_DEPLOY_CONFIG }}

pr:
if: ${{ github.event.pull_request.merged == false && github.event != 'push'}}
name: Error Check
uses: ./.github/workflows/check_err.yml

pushed-1:
if: ${{ github.event.pull_request.merged == false && github.event == 'push'}}
name: Error Check
uses: ./.github/workflows/check_err.yml

pushed-2:
if: ${{ github.event.pull_request.merged == false && github.event == 'push'}}
name: Build Nextjs
uses: ./.github/workflows/front.yml
secrets:
ECR_REPO_DEV_FRONT: ${{ secrets.ECR_REPO_DEV_FRONT }}
OIDC_ROLE: ${{ secrets.OIDC_ROLE }}
AWS_REGION: ${{ secrets.AWS_REGION }}
WEBHOOK: ${{ secrets.WEBHOOK }}
AWS_DEPLOY_APP_NAME: ${{ secrets.AWS_DEPLOY_APP_NAME }}
AWS_DEPLOY_GROUP: ${{ secrets.AWS_DEPLOY_GROUP }}
AWS_DEPLOY_CONFIG: ${{ secrets.AWS_DEPLOY_CONFIG }}
needs: pushed-1

0 comments on commit 8069dbf

Please sign in to comment.