Skip to content

Commit

Permalink
feat: standardised cd pipeline (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
proffapt committed Apr 20, 2024
1 parent 31de387 commit 3cf65f6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
52 changes: 26 additions & 26 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,76 +5,76 @@ on:
branches:
- "master"
paths:
- ".github/workflows/deploy.yaml"
- "jobs/**"
- "mediawiki/**"
- "mysql/**"
- "nginx/**"
- "docker-compose.prod.yml"
- "docker-compose.yml"
- ".github/workflows/deploy.yaml"

jobs:
pull:
name: Pull Stage
push:
name: Push Stage
runs-on: ubuntu-latest

steps:
- name: Sync with remote repository
- name: Sync local repo with remote repo
uses: appleboy/ssh-action@master
env:
WIKI_DIR: ${{ secrets.WIKI_DIR }}
PROJECT_DIR: ${{ secrets.PROJECT_DIR }}
with:
host: ${{ secrets.HOSTNAME }}
username: ${{ secrets.USERNAME }}
host: ${{ secrets.SSH_HOSTNAME }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
envs: WIKI_DIR
passphrase: ${{ secrets.SSH_PRIVATE_KEY_PASSPHRASE }}
envs: PROJECT_DIR
script_stop: true
script: |
cd "${WIKI_DIR}/"
cd "${PROJECT_DIR}/"
sudo git fetch origin
sudo git reset --hard origin/master
build:
name: Build Stage
needs: pull
needs: push
runs-on: ubuntu-latest

steps:
- name: Build the latest docker container
- name: Build the latest container(s)
uses: appleboy/ssh-action@master
env:
WIKI_DIR: ${{ secrets.WIKI_DIR }}
PROJECT_DIR: ${{ secrets.PROJECT_DIR }}
with:
host: ${{ secrets.HOSTNAME }}
username: ${{ secrets.USERNAME }}
host: ${{ secrets.SSH_HOSTNAME }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
passphrase: ${{ secrets.SSH_PRIVATE_KEY_PASSPHRASE }}
command_timeout: 60m
envs: WIKI_DIR
envs: PROJECT_DIR
script_stop: true
script: |
cd "${WIKI_DIR}/"
cd "${PROJECT_DIR}/"
sudo docker compose -f docker-compose.prod.yml build
deploy:
name: Deploy Stage
needs: [pull, build]
needs: [push, build]
runs-on: ubuntu-latest

steps:
- name: Deploy the latest build
- name: Deploy the latest build(s)
uses: appleboy/ssh-action@master
env:
WIKI_DIR: ${{ secrets.WIKI_DIR }}
PROJECT_DIR: ${{ secrets.PROJECT_DIR }}
with:
host: ${{ secrets.HOSTNAME }}
username: ${{ secrets.USERNAME }}
host: ${{ secrets.SSH_HOSTNAME }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
envs: WIKI_DIR
passphrase: ${{ secrets.SSH_PRIVATE_KEY_PASSPHRASE }}
envs: PROJECT_DIR
script_stop: true
script: |
cd "${WIKI_DIR}/"
cd "${PROJECT_DIR}/"
sudo docker compose -f docker-compose.prod.yml down
sudo docker compose -f docker-compose.prod.yml up -d
20 changes: 10 additions & 10 deletions .github/workflows/sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ on:
branches:
- "master"
paths:
- ".github/workflows/sync.yaml"
- "scripts/**"
- ".github/workflows/sync.yaml"

jobs:
pull:
name: Pull Stage
push:
name: Push Stage
runs-on: ubuntu-latest

steps:
- name: Sync with remote repository
- name: Sync local repo with remote repo
uses: appleboy/ssh-action@master
env:
WIKI_DIR: ${{ secrets.WIKI_DIR }}
PROJECT_DIR: ${{ secrets.PROJECT_DIR }}
with:
host: ${{ secrets.HOSTNAME }}
username: ${{ secrets.USERNAME }}
host: ${{ secrets.SSH_HOSTNAME }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
envs: WIKI_DIR
passphrase: ${{ secrets.SSH_PRIVATE_KEY_PASSPHRASE }}
envs: PROJECT_DIR
script_stop: true
script: |
cd "${WIKI_DIR}/"
cd "${PROJECT_DIR}/"
sudo git fetch origin
sudo git reset --hard origin/master

0 comments on commit 3cf65f6

Please sign in to comment.