Skip to content

chore(main): import dotenv 추가 #12

chore(main): import dotenv 추가

chore(main): import dotenv 추가 #12

Workflow file for this run

name: Docker Image CD
on:
push:
branches: [ "main" ]
permissions:
contents: read
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get Github Actions IP
id: ip
run: |
echo "ipv4=`dig TXT +short o-o.myaddr.l.google.com @ns1.google.com`" >> "$GITHUB_OUTPUT"
- name: Setup Java JDK
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 17
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Add Github Actions IP to Security group
run: |
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 5723 --cidr ${{ steps.ip.outputs.ipv4 }}/32
- name: Build the server
run: |
./enable_environment.sh
- name: Remove Github Actions IP From Security Group
continue-on-error: true
run: |
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 5723 --cidr ${{ steps.ip.outputs.ipv4 }}/32
- id: commit
uses: pr-mpt/actions-commit-hash@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{secrets.DOCKER_HUB_USERNAME}}
password: ${{secrets.DOCKER_HUB_PASSWORD}}
- name: Build and push
env:
TAG: ${{ env.GITHUB_SHA }}
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{secrets.DOCKER_HUB_USERNAME}}/${{ vars.REPOSITORY_NAME }}:latest, ${{secrets.DOCKER_HUB_USERNAME}}/${{ vars.REPOSITORY_NAME }}:${{ steps.commit.outputs.short }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: AWS Secrets Manager GitHub Action
uses: aws-actions/[email protected]
with:
secret-ids: dev/esc/chat/task_definition
- name: task definition to file
run: |
echo '${{ env.DEV_ESC_CHAT_TASK_DEFINITION }}' >> task_definition.json
- name: Amazon ECS "Deploy Task Definition" Action for GitHub Actions
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: task_definition.json
service: ${{ vars.SERVICE_NAME }}
cluster: ${{ vars.CLUSTER_NAME }}
wait-for-service-stability: true
wait-for-minutes: 10