Chore : github action 테스트 #95
This file contains 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
name: Docker Image CD | |
on: | |
push: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.PUBLIC_TOKEN }} | |
submodules: true | |
- name: Setup Java JDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: corretto | |
java-version: 17 | |
- name: Build the server | |
run: | |
./gradlew build | |
- 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: esc/config/task_definition | |
- name: task definition to file | |
run: | | |
echo '${{ env.ESC_CONFIG_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 |