Skip to content

[develop] main merge #19

[develop] main merge

[develop] main merge #19

Workflow file for this run

name: Deploy
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# create application.yml
- name: create application.yml
run: |
mkdir ./src/main/resources
cd ./src/main/resources
touch ./application.yml
echo "${{ secrets.APPLICATION_FILE }}" > ./application.yml
shell: bash
# grant permisson
- name: Grant permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle Wrapper
run: ./gradlew build -x test
# docker
- name: Docker hub login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker image build
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/haemo .
- name: Docker Hub push
run: docker push ${{ secrets.DOCKER_USERNAME }}/haemo
# deploy
- name: Deploy to Instance
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.AWS_USERNAME }}
key: ${{ secrets.AWS_PRIVATEKEY }}
script: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker pull ${{ secrets.DOCKER_USERNAME }}/haemo
docker stop $(docker ps -qa)
docker run -d -p 8080:8080 ${{ secrets.DOCKER_USERNAME }}/haemo
docker rm $(docker ps --filter 'status=exited' -qa)
docker image prune -f