-
Notifications
You must be signed in to change notification settings - Fork 2
59 lines (52 loc) · 2.02 KB
/
nextjs.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
name: sast link frontend
on:
push:
branches: ["master"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build Docker image
run: |
docker buildx build --platform linux/amd64 -t sast/sast-link-frontend --output type=docker,dest=sast-link-frontend.tar .
- name: Extract image
run: |
[ -d sast-link-frontend ] || mkdir sast-link-frontend
tar -xf sast-link-frontend.tar -C sast-link-frontend
- name: Copy Docker image to server
uses: easingthemes/ssh-deploy@main
with:
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_KEY }}
REMOTE_PORT: ${{ secrets.PORT }}
ARGS: "-ravc -i --delete"
SOURCE: "./sast-link-frontend/"
REMOTE_HOST: ${{ secrets.HOST }}
REMOTE_USER: ${{ secrets.USERNAME }}
TARGET: /tmp/sast-link-frontend
SCRIPT_BEFORE: |
[ -d /tmp/sast-link-frontend ] || mkdir /tmp/sast-link-frontend
SCRIPT_AFTER: |
cd /tmp/sast-link-frontend
tar -cf sast-link-frontend.tar *
### Notice: run for develop ###
# Stop and remove existing container if it exists
if [ "$(docker ps -aq -f name=sast-link-frontend)" ]; then
docker stop sast-link-frontend
docker rm sast-link-frontend
fi
# Remove existing image if it exists
if [ "$(docker images -q sast/sast-link-frontend)" ]; then
docker rmi sast/sast-link-frontend
fi
docker load -i sast-link-frontend.tar
docker run --restart always -d --name sast-link-frontend -p 127.0.0.1:3000:3000 sast/sast-link-frontend