-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (52 loc) · 1.69 KB
/
deploy_prod.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
54
55
56
57
58
59
60
name: Deploy to Production
on:
push:
branches: ['main']
jobs:
push_to_registries:
name: Push Docker image to multiple registries
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create env file
shell: bash
env:
ENV_CONTENT: ${{ secrets.ENV_PROD }}
run: |
echo "$ENV_CONTENT" > .env
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push images
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/gengar-bark:latest
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.HOST_USERNAME }}
key: ${{ secrets.HOST_SSHKEY }}
command_timeout: 20m
script: |
docker stop gengar-bark || true
docker rm gengar-bark || true
docker rmi ${{ secrets.DOCKERHUB_USERNAME }}/gengar-bark:latest || true
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/gengar-bark:latest
docker run -d --name gengar-bark \
-p 3001:3000 \
${{ secrets.DOCKERHUB_USERNAME }}/gengar-bark:latest