Skip to content

Commit

Permalink
Create gradle.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
eojinny authored Oct 30, 2023
1 parent e95f98a commit 2d0f48e
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
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 }}/community:latest
docker push ${{ secrets.DOCKER_USERNAME }}/community: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.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 }}/community:latest
docker image prune -a -f

0 comments on commit 2d0f48e

Please sign in to comment.