Skip to content

Commit 3cf65f6

Browse files
authored
feat: standardised cd pipeline (#136)
1 parent 31de387 commit 3cf65f6

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

.github/workflows/deploy.yaml

+26-26
Original file line numberDiff line numberDiff line change
@@ -5,76 +5,76 @@ on:
55
branches:
66
- "master"
77
paths:
8-
- ".github/workflows/deploy.yaml"
98
- "jobs/**"
109
- "mediawiki/**"
1110
- "mysql/**"
1211
- "nginx/**"
1312
- "docker-compose.prod.yml"
1413
- "docker-compose.yml"
14+
- ".github/workflows/deploy.yaml"
1515

1616
jobs:
17-
pull:
18-
name: Pull Stage
17+
push:
18+
name: Push Stage
1919
runs-on: ubuntu-latest
2020

2121
steps:
22-
- name: Sync with remote repository
22+
- name: Sync local repo with remote repo
2323
uses: appleboy/ssh-action@master
2424
env:
25-
WIKI_DIR: ${{ secrets.WIKI_DIR }}
25+
PROJECT_DIR: ${{ secrets.PROJECT_DIR }}
2626
with:
27-
host: ${{ secrets.HOSTNAME }}
28-
username: ${{ secrets.USERNAME }}
27+
host: ${{ secrets.SSH_HOSTNAME }}
28+
username: ${{ secrets.SSH_USERNAME }}
2929
key: ${{ secrets.SSH_PRIVATE_KEY }}
30-
passphrase: ${{ secrets.PASSPHRASE }}
31-
envs: WIKI_DIR
30+
passphrase: ${{ secrets.SSH_PRIVATE_KEY_PASSPHRASE }}
31+
envs: PROJECT_DIR
3232
script_stop: true
3333
script: |
34-
cd "${WIKI_DIR}/"
34+
cd "${PROJECT_DIR}/"
3535
sudo git fetch origin
3636
sudo git reset --hard origin/master
3737
3838
build:
3939
name: Build Stage
40-
needs: pull
40+
needs: push
4141
runs-on: ubuntu-latest
4242

4343
steps:
44-
- name: Build the latest docker container
44+
- name: Build the latest container(s)
4545
uses: appleboy/ssh-action@master
4646
env:
47-
WIKI_DIR: ${{ secrets.WIKI_DIR }}
47+
PROJECT_DIR: ${{ secrets.PROJECT_DIR }}
4848
with:
49-
host: ${{ secrets.HOSTNAME }}
50-
username: ${{ secrets.USERNAME }}
49+
host: ${{ secrets.SSH_HOSTNAME }}
50+
username: ${{ secrets.SSH_USERNAME }}
5151
key: ${{ secrets.SSH_PRIVATE_KEY }}
52-
passphrase: ${{ secrets.PASSPHRASE }}
52+
passphrase: ${{ secrets.SSH_PRIVATE_KEY_PASSPHRASE }}
5353
command_timeout: 60m
54-
envs: WIKI_DIR
54+
envs: PROJECT_DIR
5555
script_stop: true
5656
script: |
57-
cd "${WIKI_DIR}/"
57+
cd "${PROJECT_DIR}/"
5858
sudo docker compose -f docker-compose.prod.yml build
5959
6060
deploy:
6161
name: Deploy Stage
62-
needs: [pull, build]
62+
needs: [push, build]
6363
runs-on: ubuntu-latest
6464

6565
steps:
66-
- name: Deploy the latest build
66+
- name: Deploy the latest build(s)
6767
uses: appleboy/ssh-action@master
6868
env:
69-
WIKI_DIR: ${{ secrets.WIKI_DIR }}
69+
PROJECT_DIR: ${{ secrets.PROJECT_DIR }}
7070
with:
71-
host: ${{ secrets.HOSTNAME }}
72-
username: ${{ secrets.USERNAME }}
71+
host: ${{ secrets.SSH_HOSTNAME }}
72+
username: ${{ secrets.SSH_USERNAME }}
7373
key: ${{ secrets.SSH_PRIVATE_KEY }}
74-
passphrase: ${{ secrets.PASSPHRASE }}
75-
envs: WIKI_DIR
74+
passphrase: ${{ secrets.SSH_PRIVATE_KEY_PASSPHRASE }}
75+
envs: PROJECT_DIR
7676
script_stop: true
7777
script: |
78-
cd "${WIKI_DIR}/"
78+
cd "${PROJECT_DIR}/"
7979
sudo docker compose -f docker-compose.prod.yml down
8080
sudo docker compose -f docker-compose.prod.yml up -d

.github/workflows/sync.yaml

+10-10
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@ on:
55
branches:
66
- "master"
77
paths:
8-
- ".github/workflows/sync.yaml"
98
- "scripts/**"
9+
- ".github/workflows/sync.yaml"
1010

1111
jobs:
12-
pull:
13-
name: Pull Stage
12+
push:
13+
name: Push Stage
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- name: Sync with remote repository
17+
- name: Sync local repo with remote repo
1818
uses: appleboy/ssh-action@master
1919
env:
20-
WIKI_DIR: ${{ secrets.WIKI_DIR }}
20+
PROJECT_DIR: ${{ secrets.PROJECT_DIR }}
2121
with:
22-
host: ${{ secrets.HOSTNAME }}
23-
username: ${{ secrets.USERNAME }}
22+
host: ${{ secrets.SSH_HOSTNAME }}
23+
username: ${{ secrets.SSH_USERNAME }}
2424
key: ${{ secrets.SSH_PRIVATE_KEY }}
25-
passphrase: ${{ secrets.PASSPHRASE }}
26-
envs: WIKI_DIR
25+
passphrase: ${{ secrets.SSH_PRIVATE_KEY_PASSPHRASE }}
26+
envs: PROJECT_DIR
2727
script_stop: true
2828
script: |
29-
cd "${WIKI_DIR}/"
29+
cd "${PROJECT_DIR}/"
3030
sudo git fetch origin
3131
sudo git reset --hard origin/master

0 commit comments

Comments
 (0)