-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (40 loc) · 1.41 KB
/
auto-deploy.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
name: Deploy
on:
push:
workflow_dispatch:
jobs:
deploy:
name: Build and deploy image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get latest tag
uses: actions-ecosystem/action-get-latest-tag@v1
id: get-latest-tag
- name: Build Docker image
run: |
touch .env
echo "${{ secrets.ENV_FILE }}" > .env
docker build . -t carberra/website:${{ steps.get-latest-tag.outputs.tag }}
docker save -o carberra-website.tar carberra/website:${{ steps.get-latest-tag.outputs.tag }}
- name: SCP image to server
uses: appleboy/scp-action@v0.1.3
with:
username: parafoxia
host: ${{ secrets.HOST }}
key: ${{ secrets.PRIVATE_KEY }}
source: 'carberra-website.tar'
target: '/tmp/carberra-website'
rm: true
- name: Run deploy script via SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: parafoxia
key: ${{ secrets.PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
script: |
docker stop carberra-website
docker load --input /tmp/carberra-website/carberra-website.tar
docker run -p 127.0.0.1:3000:3000 --name carberra-website --rm -d carberra/website:${{ steps.get-latest-tag.outputs.tag }}