Skip to content

개발계 배포

개발계 배포 #49

Workflow file for this run

name: "개발계 배포"
on:
workflow_dispatch:
inputs:
version:
description: "Release Version"
required: true
type: string
default: 'v1.0.0'
jobs:
deploy:
name: community-deploy
runs-on: ubuntu-latest
environment: "dev"
steps:
- name: checkout@v2
uses: actions/checkout@v4
- name: Version
id: version
run: |
VERSION=${VERSIONING#v}-${{ github.run_id }}
echo "::set-output name=version::$VERSION"
env:
VERSIONING: ${{ github.event.inputs.version }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
cache: gradle
- name: Run chmod to make gradlew executable
run: chmod +x ./gradlew
- name: Setup Docker compose
run: docker-compose -f "docker/test/docker-compose.yml" up -d
- name: Test
run: ./gradlew test
- name: Build Community API Image
id: build
env:
DOCKER_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
DOCKER_REPOSITORY: threedollar-community-api
IMAGE_TAG: ${{ steps.version.outputs.version }}
PINPOINT_COLLECTOR_IP: ${{ secrets.PINPOINT_COLLECTOR_IP_DEV }}
run: |
docker build -t $DOCKER_REGISTRY/$DOCKER_REPOSITORY:$IMAGE_TAG --build-arg PROFILE=DEV --build-arg COLLECTOR_IP=${PINPOINT_COLLECTOR_IP} -f ./threedollar-application/Dockerfile .
docker tag $DOCKER_REGISTRY/$DOCKER_REPOSITORY:$IMAGE_TAG $DOCKER_REGISTRY/$DOCKER_REPOSITORY:latest
docker push $DOCKER_REGISTRY/$DOCKER_REPOSITORY:$IMAGE_TAG
docker push $DOCKER_REGISTRY/$DOCKER_REPOSITORY:latest
echo "::set-output name=image::$DOCKER_REGISTRY/$DOCKER_REPOSITORY:$IMAGE_TAG"
echo "🐇 Build Image >> $DOCKER_REPOSITORY$IMAGE_TAG"
- name: Download task definition
id: download-task-definition
run: |
aws ecs describe-task-definition --task-definition threedollar-community-api-dev --query taskDefinition > task-definition-community-dev.json
echo "task-definition=$GITHUB_WORKSPACE/task-definition-community-dev.json" >> $GITHUB_OUTPUT
- name: Update Amazon ECS task definition
id: render-api-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ steps.download-task-definition.outputs.task-definition }}
container-name: threedollar-community-api-dev
image: ${{ steps.build.outputs.image }}
- name: Deploy to Amazon ECS service
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.render-api-container.outputs.task-definition }}
cluster: three-dollar-community-ecs
service: threedollar-community-api-dev
wait-for-service-stability: true