-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (51 loc) · 2.15 KB
/
dev-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
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: Workflow for Development Environment Deployment
on:
push:
branches:
- main
env:
DEV_CONFIG_ENV: ${{ secrets.DEV_CONFIG_ENV }}
DEV_TARGET_PLATFORMS: ${{ secrets.DEV_TARGET_PLATFORMS }}
REGISTRY: ${{ secrets.REGISTRY }}
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
REGISTRY_IMAGE: ${{ secrets.REGISTRY_IMAGE }}
REGISTRY_ACCESS_TOKEN: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
jobs:
Dev-Deployment:
name: Development Deployment
runs-on: ubuntu-22.04
steps:
- name: Checkout Sources
uses: actions/checkout@v3
- name: Sign in to Container Registry
run: echo $REGISTRY_ACCESS_TOKEN | docker login -u $REGISTRY_USER --password-stdin $REGISTRY
- name: Build and Tag Image
run: |
docker build \
--platform $DEV_TARGET_PLATFORMS \
-t "$REGISTRY/$REGISTRY_IMAGE:${{ github.sha }}" .
docker tag "$REGISTRY/$REGISTRY_IMAGE:${{ github.sha }}" "$REGISTRY/$REGISTRY_IMAGE:latest"
- name: Publish to Container Registry
run: docker push "$REGISTRY/$REGISTRY_IMAGE:latest"
- name: Pull Latest Image and Run Container
uses: appleboy/ssh-action@v0.1.10
with:
host: ${{ secrets.DEV_SSH_HOST }}
username: ${{ secrets.DEV_SSH_USER }}
key: ${{ secrets.DEV_SSH_PRIVATEKEY }}
envs: DEV_CONFIG_ENV,REGISTRY_ACCESS_TOKEN,REGISTRY_USER,REGISTRY,REGISTRY_IMAGE
script: |
mkdir -pv ./app/lexicapi
cd ./app/lexicapi
echo $DEV_CONFIG_ENV | tr ' ' '\n' > .env
mkdir ./log
sudo chown :lexica ./log && sudo chmod 0775 ./log && sudo chmod g+s ./log
echo $REGISTRY_ACCESS_TOKEN | docker login -u $REGISTRY_USER --password-stdin $REGISTRY
docker rm -f lexicapi-dev
docker pull "$REGISTRY/$REGISTRY_IMAGE:latest"
docker run -d --name lexicapi-dev \
--restart always \
-v "$(pwd)/.env:/app/lexicapi/.env:ro" \
-v "$(pwd)/log:/app/lexicapi/log:z" \
-p "8080:8080" \
"$REGISTRY/$REGISTRY_IMAGE:latest"