-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (50 loc) · 1.54 KB
/
cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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 }}