docs: PR, Issue Template, Assign Reviewer #11
Workflow file for this run
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: 배포 자동화 파이프라인 | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GIT_TOKEN }} | |
submodules: true | |
- name: Setup Java 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: Update Git submodules | |
run: git submodule update --remote --recursive | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew clean build --debug | |
- name: Get current time | |
uses: 1466587594/get-current-time@v2 | |
id: current-time | |
with: | |
format: YYYY-MM-DDTHH-mm-ss | |
utcOffset: "+09:00" | |
- name: Show Current Time | |
run: echo "CurrentTime=${{steps.current-time.outputs.formattedTime}}" | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ap-northeast-2 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Build, tag, and push image to Amazon ECR | |
run: | | |
docker build -t vacgom:${{steps.current-time.outputs.formattedTime}} . | |
docker tag vacgom:${{steps.current-time.outputs.formattedTime}} ${{ secrets.ECR_URI }}:${{steps.current-time.outputs.formattedTime}} | |
docker push ${{ secrets.ECR_URI }}:${{steps.current-time.outputs.formattedTime}} | |
- name: SSH into EC2 instance | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USERNAME }} | |
key: ${{ secrets.EC2_PRIVATE_KEY }} | |
port: ${{ secrets.EC2_SSH_PORT }} | |
script: | | |
aws ecr get-login-password | docker login --username AWS --password-stdin ${{ secrets.ECR_URI }} | |
docker pull ${{ secrets.ECR_URI }}:${{ steps.current-time.outputs.formattedTime }} | |
docker ps -f name=vacgom-api -q | xargs --no-run-if-empty docker container stop | |
docker ps -a -f name=vacgom-api -q | xargs --no-run-if-empty docker container rm | |
docker run -d --name vacgom-api -p 80:8080 ${{ secrets.ECR_URI }}:${{ steps.current-time.outputs.formattedTime }} |