feat(workflows/deploy): update server #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: 'zulu' # Alternative distribution options are available | |
- name: Cache Gradle packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
restore-keys: ${{ runner.os }}-gradle | |
- name: Login to Docker Hub | |
run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u ${{ secrets.DOCKER_HUB_USER }} --password-stdin | |
- name: Build project | |
run: ./gradlew bootWar | |
- name: Build image | |
run: docker compose build | |
- name: Push image | |
run: docker compose push | |
- name: Update server | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SERVER_SSH_HOST }} | |
port: ${{ secrets.SERVER_SSH_PORT }} | |
username: ${{ secrets.SERVER_SSH_USER }} | |
key: ${{ secrets.SERVER_SSH_KEY }} | |
script: docker compose pull && docker compose up -d | |