Skip to content

Merge pull request #35 from kusitms-28th-Meetup-E/hotfix #81

Merge pull request #35 from kusitms-28th-Meetup-E/hotfix

Merge pull request #35 from kusitms-28th-Meetup-E/hotfix #81

Workflow file for this run

name: Java CI with Gradle
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
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'
- name: Make application.yml
run: |
mkdir -p src/main/resources
echo "$APPLICATION" > src/main/resources/application.yml
env:
APPLICATION: ${{ secrets.APPLICATION }}
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build -x test
- name: Docker build
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t app .
docker tag app ${{ secrets.DOCKER_USERNAME }}/member:latest
docker push ${{ secrets.DOCKER_USERNAME }}/member:latest
- name: docker-compose.yml
uses: appleboy/scp-action@master
with:
username: ec2-user
host: ${{ secrets.HOST }}
key: ${{ secrets.PRIVATE_KEY }}
port: ${{ secrets.PORT }}
source: "./docker-compose-member.yml"
target: "/home/ec2-user/"
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ec2-user
key: ${{ secrets.PRIVATE_KEY }}
script: |
docker pull ${{ secrets.DOCKER_USERNAME }}/member:latest
docker image prune -a -f
docker-compose up -d