Skip to content

Merge pull request #106 from Donut-DONationUTile/hotfix/googleid #99

Merge pull request #106 from Donut-DONationUTile/hotfix/googleid

Merge pull request #106 from Donut-DONationUTile/hotfix/googleid #99

Workflow file for this run

name: Java CI with Gradle
on:
push:
branches: [ "main" ]
jobs:
# Build
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
# Checkout repository
- name: Checkout repository
uses: actions/checkout@v3
with:
token: ${{ secrets.TOKEN }}
submodules: true
# Set up JDK 17
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
# Cache Gradle dependencies
- name: Cache Gradle dependencies
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# Build project with Gradle (excluding tests)
- name: Build with Gradle
run: ./gradlew clean build -x test
# Docker build and push
- name: Docker build and push
run: |
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}
docker build -t ${{ secrets.DOCKERHUB_REPOSITORY }} .
docker tag ${{ secrets.DOCKERHUB_REPOSITORY }} ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:${GITHUB_SHA::7}
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:${GITHUB_SHA::7}
# Deploy
deploy:
runs-on: ubuntu-latest
needs: build
steps:
# Checkout repository
- name: Checkout repository
uses: actions/checkout@v3
# Deploy using SSH
- name: Deploy application
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VM_INSTANCE }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
sudo docker-compose down
sudo docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:${GITHUB_SHA::7}
sudo docker tag ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:${GITHUB_SHA::7} donut
sudo docker-compose up -d --remove-orphans