[Feat] 디스코드 연결 구현 (#42) #56
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: Dev Deploy to AWS | |
on: | |
push: | |
branches: [ "develop" ] | |
env: | |
DOCKERHUB_IMAGE_NAME: gigedi-server | |
jobs: | |
build-deploy: | |
runs-on: ubuntu-latest | |
environment: DEV | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Gradle Caching | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Grant Permissions for Gradle build | |
run: chmod +x gradlew | |
- name: Gradle building | |
run: ./gradlew build -x test | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Extract Docker metadata | |
id: metadata | |
uses: docker/metadata-action@v5.5.0 | |
with: | |
images: ${{ secrets.DOCKER_USERNAME }}/${{ env.DOCKERHUB_IMAGE_NAME }} | |
tags: | | |
type=sha,prefix= | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.metadata.outputs.tags }} | |
# - name: Create .env file from GitHub Secrets | |
# run: | | |
# echo "${{ secrets.ENV_FILE }}" > .env | |
# | |
# - name: Copy .env and docker-compose.yml to EC2 | |
# uses: appleboy/scp-action@master | |
# with: | |
# host: ${{ secrets.AWS_EC2_IP }} | |
# username: ${{ secrets.AWS_EC2_USER }} | |
# key: ${{ secrets.AWS_EC2_SSH_KEY }} | |
# source: | | |
# .env | |
# docker-compose.yml | |
# target: "/home/ubuntu/" | |
# port: 22 | |
- name: Deploy on EC2 | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.AWS_EC2_IP }} | |
username: ${{ secrets.AWS_EC2_USER }} | |
key: ${{ secrets.AWS_EC2_SSH_KEY }} | |
port: 22 | |
script: | | |
cd /home/ubuntu | |
sudo docker pull cowboysj/shoot:latest | |
docker-compose down | |
docker-compose up -d |