some refactoring #39
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 | |
permissions: | |
contents: read | |
packages: write | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-package-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Set Up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.22.0 | |
- name: Install Dependencies | |
run: go mod download | |
- name: Lint | |
run: go vet ./... | |
- name: Build | |
run: go build -o dwelt | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
tags: ghcr.io/ruskaof/dwelt:latest | |
build-args: | | |
DWELT_JWT_KEY=${{ secrets.JWT_KEY }} | |
DWELT_WORKFLOW_RUN_NUMBER=${{ github.run_number }} | |
DB_HOST=${{ secrets.DB_HOST }} | |
DB_PORT=5432 | |
DB_USER=${{ secrets.DB_USER }} | |
DB_PASSWORD=${{ secrets.DB_PASSWORD }} | |
DB_NAME=dweltdb | |
- name: Deploy to VPS | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.VPS_HOST }} | |
username: ${{ secrets.VPS_USERNAME }} | |
password: ${{ secrets.VPS_PASSWORD }} | |
script: | | |
docker stop dwelt || true | |
docker rm dwelt || true | |
docker pull ghcr.io/ruskaof/dwelt:latest | |
docker run -d --name dwelt -p 8080:8080 ghcr.io/ruskaof/dwelt:latest |