-
Notifications
You must be signed in to change notification settings - Fork 1
32 lines (30 loc) · 1.23 KB
/
deployment.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
name: Deploying to VPS
on:
push:
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Calculate short hash
run: |
shortHash=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$shortHash" >> $GITHUB_ENV
- name: SSH setup and run commands
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
key: ${{ secrets.SSH_KEY }}
username: ${{ secrets.SSH_USER }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
script: |
cd ./deploy/${{ github.event.repository.name }}
git pull
docker rm --force ${{ github.event.repository.name }}-deploy 2> /dev/null
docker build -t ${{ github.event.repository.owner.name }}/${{ github.event.repository.name }}:${{ env.COMMIT_SHORT_SHA }} --quiet .
docker run --detach --name ${{ github.event.repository.name }}-deploy ${{ github.event.repository.owner.name }}/${{ github.event.repository.name }}:${{ env.COMMIT_SHORT_SHA }}
docker container prune --force && docker image prune --all --force