Skip to content

feat: Controller and Service for Post #12

feat: Controller and Service for Post

feat: Controller and Service for Post #12

Workflow file for this run

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
name: Java CI with Gradle
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Copy application.properties into runner
run: |
mkdir -p ./src/main/resources
touch ./src/main/resources/application.properties
echo "${{secrets.APPLICATION_YML}}" > ./src/main/resources/application.properties
- name: Build with Gradle
run: |
chmod +x gradlew
./gradlew build
- name: Docker Login
# You may pin to the exact commit or the version.
# uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20
uses: docker/[email protected]
with:
# Server address of Docker registry. If not set then will default to Docker Hub
registry: ghcr.io
# Username used to log against the Docker registry
username: ${{ secrets.GHCR_USERNAME }}
# Password or personal access token used to log against the Docker registry
password: ${{ secrets.GHCR_PASSWORD }}
- name: Build and push
uses: docker/[email protected]
with:
context: ./
push: true
tags: ghcr.io/peageon/ssock:latest
deploy:
runs-on: ubuntu-latest
permissions: write-all
needs: build
steps:
- uses: actions/checkout@v4
- name: Copy docker-compose into instance
uses: appleboy/scp-action@master #이미 존재하는 경우 덮어씀
with:
host: ${{secrets.GCP_HOST}}
username: ${{secrets.GCP_USERNAME}}
key: ${{secrets.GCP_PRIVATEKEY}}
source: "./docker-compose.yml"
target: "/home/${{secrets.GCP_USERNAME}}"
strip_components: 3
overwrite: true
debug: true
- name: Deploy to Instance
uses: appleboy/ssh-action@master
with:
host: ${{secrets.GCP_HOST}}
username: ${{secrets.GCP_USERNAME}}
key: ${{secrets.GCP_PRIVATEKEY}}
script: |
sudo docker login -u ${{ secrets.GHCR_USERNAME }} -p ${{ secrets.GHCR_PASSWORD }}
sudo docker pull ${{ secrets.GHCR_USERNAME }}/ssock:latest
sudo docker rm -f $(docker ps -qa) 2>/dev/null || true
cd /home/${{secrets.GCP_USERNAME}}
sudo docker-compose up -d
sudo docker image prune -f