Skip to content

Commit

Permalink
feat: workflow 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
GIVEN53 committed Feb 7, 2024
1 parent 2f0bfb8 commit 2660917
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/aws-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: AWS ECR Login

on:
workflow_call:

jobs:
aws-config:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

- name: login to ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'
33 changes: 9 additions & 24 deletions .github/workflows/deploy-fluentbit.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
name: Deploy to AWS

on:
push:
branches:
- main
paths:
- 'fluentbit/**'
- '.github/workflows/**'

env:
ECR_URI: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.ap-northeast-2.amazonaws.com
Expand All @@ -16,34 +19,14 @@ env:
TAG: latest

jobs:
aws-config:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./fluentbit
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

- name: login to ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'false'

deploy-dev:
runs-on: ubuntu-latest
env:
working-directory: ./fluentbit
needs: aws-config
steps:
- name: Configure aws
uses: ./.github/workflows/aws-config.yml

- name: Build and push image to Amazon ECR
run: |
docker build -t ${{ env.ECR_URI }}/${{ env.DEV_REPO }}:${{ env.TAG }} .
Expand All @@ -66,8 +49,10 @@ jobs:
runs-on: ubuntu-latest
env:
working-directory: ./fluentbit
needs: aws-config
steps:
- name: Configure aws
uses: ./.github/workflows/aws-config.yml

- name: Build and push image to Amazon ECR
run: |
docker build -t ${{ env.ECR_URI }}/${{ env.PROD_REPO }}:${{ env.TAG }} .
Expand Down

0 comments on commit 2660917

Please sign in to comment.