Skip to content

CD

CD #8

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
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to ghcr
uses: docker/login-action@v3
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/ssh-action@v0.1.8
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 vixorcrypt
docker rm vixorcrypt
docker run --name vixorcrypt -p ${{ secrets.DOCKER_PORT }}:10002 \
--network custom-bridge \
--restart always -d ghcr.io/${{ github.repository }}:${{ github.sha }}