-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (41 loc) · 1.41 KB
/
deploy.yaml
File metadata and controls
46 lines (41 loc) · 1.41 KB
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
name: Deploy
permissions:
contents: read
on:
workflow_run:
workflows: ["Publish"]
types:
- completed
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
- name: Copy compose file to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.PROD_HOST }}
username: ${{ secrets.PROD_USERNAME }}
key: ${{ secrets.PROD_SSH_KEY }}
source: "compose.yaml"
target: "/opt/${{ github.event.repository.name }}/"
- name: Deploy to production
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.PROD_HOST }}
username: ${{ secrets.PROD_USERNAME }}
key: ${{ secrets.PROD_SSH_KEY }}
script: |
export COMPOSE_PATH="/opt/${{ github.event.repository.name }}/compose.yaml"
# Create docker config directory if it doesn't exist
mkdir -p ~/.docker
# Login using docker config to avoid token in shell history
echo '{ "auths": { "ghcr.io": { "auth": "${{ secrets.GITHUB_TOKEN }}" } } }' > ~/.docker/config.json
docker compose -f $COMPOSE_PATH pull
docker compose -f $COMPOSE_PATH down
docker compose -f $COMPOSE_PATH up -d
# Remove the config file after we're done
rm ~/.docker/config.json