Update README.md #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: dohands server | |
on: | |
push: | |
# branches: | |
# - "main" | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Gradle Caching | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Set up GCP credentials | |
env: | |
GCP_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS }} | |
FIREBASE_KEY: ${{ secrets.FIREBASE_KEY }} | |
run: | | |
mkdir -p src/main/resources/firebase | |
echo "$GCP_CREDENTIALS" > src/main/resources/credentials.json | |
echo "$FIREBASE_KEY" > src/main/resources/firebase/firebasekey.json | |
- name: Login to Docker Registry | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DI }} | |
password: ${{ secrets.DP }} | |
- name: Build and Push Docker Image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: | | |
${{ secrets.DI }}/dohands:latest | |
- name: Deploy to Server | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_PRIVATE_PATH }} | |
username: ubuntu | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
script: | | |
sudo docker-compose down | |
sudo docker pull ${{ secrets.DI }}/dohands:latest | |
sudo docker-compose up -d | |
sudo docker volume prune |