Skip to content

Commit d2f37be

Browse files
committed
Update workflows
1 parent 5be2505 commit d2f37be

File tree

5 files changed

+146
-15
lines changed

5 files changed

+146
-15
lines changed

.github/workflows/rpgf3-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ jobs:
3737
docker image prune -a --force
3838
git checkout rpgf3
3939
git pull origin rpgf3
40-
docker-compose up -d --build
40+
docker-compose up -d --build
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
name: production-deploy-pipeline
1+
name: rf4-deploy-pipeline
22

33
on:
44
push:
55
branches:
6-
- master
6+
- rf4
77

88
jobs:
99
deploy:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- name: SSH and Redeploy Production
12+
- name: SSH and Redeploy rf4
1313
uses: appleboy/[email protected]
1414
with:
1515
host: ${{ secrets.PROD_HOST }}
@@ -20,8 +20,8 @@ jobs:
2020
cd rpgf4-pw-backend
2121
docker-compose down -v
2222
docker image prune -a --force
23-
git checkout master
24-
git reset --hard origin/master
25-
git pull origin master
23+
git checkout rf4
24+
git reset --hard origin/rf4
25+
git pull origin rf4
2626
docker-compose build --no-cache
27-
docker-compose up -d
27+
docker-compose up -d
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
name: staging-deploy-pipeline
1+
name: rf4-staging-deploy-pipeline
22

33
on:
44
push:
55
branches:
6-
- staging
6+
- rf4-staging
77

88
jobs:
99
deploy:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- name: SSH and Redeploy Staging
12+
- name: SSH and Redeploy rf4-staging
1313
uses: appleboy/[email protected]
1414
with:
1515
host: ${{ secrets.STAGING_HOST }}
@@ -20,8 +20,8 @@ jobs:
2020
cd rpgf4-pw-backend
2121
docker-compose down -v
2222
docker image prune -a --force
23-
git checkout staging
24-
git reset --hard origin/staging
25-
git pull origin staging
23+
git checkout rf4-staging
24+
git reset --hard origin/rf4-staging
25+
git pull origin rf4-staging
2626
docker-compose build --no-cache
27-
docker-compose up -d
27+
docker-compose up -d
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: rpgf5-prod-deploy-pipeline
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
- name: Set up QEMU
16+
uses: docker/setup-qemu-action@v3
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v3
19+
- name: Login to GitHub Container Registry
20+
uses: docker/login-action@v3
21+
with:
22+
registry: ghcr.io
23+
username: ${{ github.actor }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
25+
- name: Build and push
26+
uses: docker/build-push-action@v6
27+
with:
28+
context: .
29+
push: true
30+
tags: ghcr.io/generalmagicio/rpgf5-be:main
31+
32+
deploy:
33+
runs-on: ubuntu-latest
34+
needs: publish
35+
steps:
36+
- name: SSH and Redeploy Production
37+
uses: appleboy/[email protected]
38+
with:
39+
host: ${{ secrets.RPGF5_PROD_HOST }}
40+
username: ${{ secrets.RPGF5_PROD_USERNAME }}
41+
key: ${{ secrets.RPGF5_PROD_PRIVATE_KEY }}
42+
port: ${{ secrets.SSH_PORT }}
43+
script: |
44+
cd pw-backend
45+
git reset --hard HEAD~1
46+
git checkout master
47+
git pull origin master
48+
docker image prune -a --force
49+
docker compose -f docker-compose-prod.yml pull
50+
51+
## Update each backend service one by one
52+
docker compose -f docker-compose-prod.yml up -d --no-deps --scale pw-backend1=0 --scale pw-backend2=1
53+
docker compose -f docker-compose-prod.yml up -d
54+
# Check the health of pw-backend1
55+
if [ "$(docker inspect --format='{{json .State.Status}}' pw-backend1)" != "\"running\"" ]; then
56+
echo "pw-backend1 is not running, stopping deployment"
57+
exit 1
58+
fi
59+
60+
docker compose -f docker-compose-prod.yml up -d --no-deps --scale pw-backend1=1 --scale pw-backend2=0
61+
docker compose -f docker-compose-prod.yml up -d
62+
# Check the health of pw-backend2
63+
if [ "$(docker inspect --format='{{json .State.Status}}' pw-backend2)" != "\"running\"" ]; then
64+
echo "pw-backend2 is not running, stopping deployment"
65+
exit 1
66+
fi
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: rpgf5-staging-deploy-pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- staging
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
- name: Set up QEMU
15+
uses: docker/setup-qemu-action@v3
16+
- name: Set up Docker Buildx
17+
uses: docker/setup-buildx-action@v3
18+
- name: Login to GitHub Container Registry
19+
uses: docker/login-action@v3
20+
with:
21+
registry: ghcr.io
22+
username: ${{ github.actor }}
23+
password: ${{ secrets.GITHUB_TOKEN }}
24+
- name: Build and push
25+
uses: docker/build-push-action@v6
26+
with:
27+
context: .
28+
push: true
29+
tags: ghcr.io/generalmagicio/rpgf5-be:staging
30+
31+
deploy:
32+
runs-on: ubuntu-latest
33+
needs: publish
34+
steps:
35+
- name: SSH and Redeploy Production
36+
uses: appleboy/[email protected]
37+
with:
38+
host: ${{ secrets.RPGF5_STAGING_HOST }}
39+
username: ${{ secrets.RPGF5_STAGING_USERNAME }}
40+
key: ${{ secrets.RPGF5_STAGING_PRIVATE_KEY }}
41+
port: ${{ secrets.SSH_PORT }}
42+
script: |
43+
cd pw-backend
44+
git reset --hard HEAD~1
45+
git checkout staging
46+
git pull origin staging
47+
docker image prune -a --force
48+
docker compose -f docker-compose-staging.yml pull
49+
50+
## Update each backend service one by one
51+
docker compose -f docker-compose-staging.yml up -d --no-deps --scale pw-backend1=0 --scale pw-backend2=1
52+
docker compose -f docker-compose-staging.yml up -d
53+
# Check the health of pw-backend1
54+
if [ "$(docker inspect --format='{{json .State.Status}}' pw-backend1)" != "\"running\"" ]; then
55+
echo "pw-backend1 is not running, stopping deployment"
56+
exit 1
57+
fi
58+
59+
docker compose -f docker-compose-staging.yml up -d --no-deps --scale pw-backend1=1 --scale pw-backend2=0
60+
docker compose -f docker-compose-staging.yml up -d
61+
# Check the health of pw-backend2
62+
if [ "$(docker inspect --format='{{json .State.Status}}' pw-backend2)" != "\"running\"" ]; then
63+
echo "pw-backend2 is not running, stopping deployment"
64+
exit 1
65+
fi

0 commit comments

Comments
 (0)