-
Notifications
You must be signed in to change notification settings - Fork 2
87 lines (74 loc) · 2.54 KB
/
dev-mobile.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: dev-mobile
env:
DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
ACTIONS_STEP_DEBUG: true
on:
push:
branches: [development]
paths:
- 'mobile/**'
- '.github/workflows/dev-mobile.yml'
jobs:
Build:
runs-on: self-hosted-dev
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Get the short Git commit hash
id: vars
run: |
echo "COMMIT_HASH=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Get metadata
id: meta
uses: docker/metadata-action@v5
with:
images: 5scontrol/5scontrol_front_mobile
tags: |
"${{ env.COMMIT_HASH }}"
latest
continue-on-error: false
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_TOKEN }}
continue-on-error: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker images
uses: docker/build-push-action@v6
with:
context: ./mobile
push: true
build-args: |
VITE_API_BASE_URL=${{secrets.API_BASE_URL}}
BASE_URL=${{secrets.BASE_URL}}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=5scontrol/5scontrol_front_mobile:cache
cache-to: type=registry,ref=5scontrol/5scontrol_front_mobile:cache,mode=max
continue-on-error: false
env:
DOCKER_BUILDKIT: 1
Deploy:
runs-on: self-hosted-dev
needs: Build
steps:
- name: Pull the latest Docker image
working-directory: /home/server/reps/server-
run: |
echo "Pulling latest Docker image for 5scontrol_front_mobile..."
docker-compose pull 5scontrol_front_mobile
- name: Stop and remove the old server container
working-directory: /home/server/reps/server-
run: |
echo "Stopping and removing the old 5scontrol_front_mobile and nginx container..."
docker-compose rm -fs nginx 5scontrol_front_mobile
- name: Recreate and restart server container
working-directory: /home/server/reps/server-
run: |
echo "Recreating and restarting the 5scontrol_front_mobile and nginx container..."
docker-compose up -d --no-deps nginx 5scontrol_front_mobile