Skip to content

Merge pull request #325 from urizennnn/feat/2FA #9

Merge pull request #325 from urizennnn/feat/2FA

Merge pull request #325 from urizennnn/feat/2FA #9

Workflow file for this run

name: Dev Deployment
on:
workflow_dispatch:
push:
branches:
- dev
jobs:
build_docker_image:
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build Docker image
run: docker build -t golang_dev .
- name: Save and compress Docker image
run: docker save golang_dev | gzip > golang_dev.tar.gz
- name: Upload Docker image
uses: actions/upload-artifact@v4
with:
name: golang_dev
path: golang_dev.tar.gz
upload_docker_image:
runs-on: ubuntu-latest
needs: build_docker_image
if: github.event.repository.fork == false
environment:
name: "development"
url: ${{ vars.URL }}
steps:
- name: Download Docker image
uses: actions/download-artifact@v4
with:
name: golang_dev
path: .
- name: Copy image to server
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
source: golang_dev.tar.gz
target: "/tmp"
run_docker_container:
runs-on: ubuntu-latest
needs: upload_docker_image
if: github.event.repository.fork == false
environment: development
env:
SSH_USERNAME: ${{ secrets.SSH_USERNAME }}
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }}
steps:
- name: Deploy on server
uses: appleboy/[email protected]
with:
host: ${{ env.HOST }}
username: ${{ env.USERNAME }}
password: ${{ env.PASSWORD }}
script: |
gunzip -c /tmp/golang_dev.tar.gz | docker load
rm -f /tmp/golang_dev.tar.gz
cd ~/deployments/development
git reset --hard
git pull origin dev
docker compose -f docker-compose.yml up -d