Skip to content

Merge pull request #49 from one-dream-us/dev #5

Merge pull request #49 from one-dream-us/dev

Merge pull request #49 from one-dream-us/dev #5

Workflow file for this run

name: Thisismoney deployment actions
on:
push:
branches: [ "main" ]
jobs:
build-project:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
# Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
- name: Set config file
run: |
rm -f
echo "${{secrets.APPLICATION_YML}}" | base64 --decode > src/main/resources/application.yml
- name: Build with Gradle Wrapper
run: ./gradlew build -x test
- name: Build docker image
run: |
docker login -u ${{secrets.DOCKER_USER}} -p ${{secrets.DOCKER_PASSWORD}}
docker buildx build --platform linux/amd64 -t ${{secrets.DOCKER_USER}}/thisismoney-app .
docker push ${{secrets.DOCKER_USER}}/thisismoney-app:latest
deploy-project:
runs-on: ubuntu-latest
needs: build-project
steps:
- name: Excute remote ssh cmmands & Run App
uses: appleboy/ssh-action@v0.1.6 # ssh 접속하는 오픈소스
with:
host: ${{ secrets.EC2_HOST }} # 인스턴스 IP
username: ${{ secrets.EC2_USER_NAME }} # 우분투 아이디
key: ${{ secrets.EC2_PEM_KEY }} # ec2 instance pem key
script: | # 실행할 스크립트
docker login -u ${{secrets.DOCKER_USER}} -p ${{secrets.DOCKER_PASSWORD}}
cd ~/thisismoney
docker-compose down
docker rmi ${{secrets.DOCKER_USER}}/thisismoney-app
docker-compose pull
docker-compose up -d