Skip to content

CD

CD #3

Workflow file for this run

name: CD
on:
workflow_run:
workflows:
- "CI"
types:
- completed
branches:
- master
jobs:
push_container:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to ghcr
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
run: |
docker build . --tag ghcr.io/${{ github.repository }}:${{ github.sha }}
docker push ghcr.io/${{ github.repository }}:${{ github.sha }}
deploy:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
needs: [push_container]
steps:
- name: Deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
port: ${{ secrets.SSH_PORT }}
script: |
docker pull ghcr.io/${{ github.repository }}:${{ github.sha }}
docker stop vixorcypt
docker rm vixorcypt
docker run --name vixorcypt -p ${{ secrets.DOCKER_PORT }}:5173 \
--network custom-bridge \
--restart always -d ghcr.io/${{ github.repository }}:${{ github.sha }}