-
Notifications
You must be signed in to change notification settings - Fork 2
108 lines (93 loc) · 3.31 KB
/
stage-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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: Build and deploy mobile (stage)
env:
DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
DOCKER_TAG: ${{ github.event.pull_request.title }}
PR_BODY: ${{ github.event.pull_request.body }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTIONS_STEP_DEBUG: true
on:
pull_request:
types:
- closed
branches:
- main
paths:
- 'mobile/**'
- '.github/workflows/dev-mobile.yml'
- '.github/workflows/stage-mobile.yml'
jobs:
Build:
if: github.event.pull_request.merged == true
runs-on: self-hosted-stage
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Get metadata
id: meta
uses: docker/metadata-action@v5
with:
images: 5scontrol/5scontrol_front_mobile
tags: |
stage-${{env.DOCKER_TAG}}
stage-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_STAGE}}
BASE_URL=${{secrets.BASE_URL}}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=5scontrol/5scontrol_front_mobile:stage-cache
cache-to: type=registry,ref=5scontrol/5scontrol_front_mobile:stage-cache,mode=max
continue-on-error: false
env:
DOCKER_BUILDKIT: 1
Deploy:
runs-on: self-hosted-stage
needs: Build
steps:
- name: Pull the latest Docker image
working-directory: /home/admin1/reps/server
run: |
echo "Pulling latest Docker image for 5scontrol_front_mobile..."
FRONT_MOBILE_TAG=stage-${{ env.DOCKER_TAG }} docker-compose pull 5scontrol_front_mobile
- name: Stop and remove the old server container
working-directory: /home/admin1/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/admin1/reps/server
run: |
echo "Recreating and restarting the 5scontrol_front_mobile and nginx container..."
FRONT_MOBILE_TAG=stage-${{ env.DOCKER_TAG }} docker-compose up -d --no-deps nginx 5scontrol_front_mobile
# CreateRelease:
# runs-on: self-hosted-stage
# needs: Deploy
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Create a GitHub release
# uses: actions/create-release@v1
# id: create_release
# with:
# tag_name: 'mobile-v${{ env.DOCKER_TAG }}'
# release_name: 'Mobile release v${{ env.DOCKER_TAG }}'
# body: ${{ env.PR_BODY }}
# draft: false
# prerelease: false