-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: Continuous Deployment Pipeline | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
paths-ignore: | ||
- "**.md" | ||
- "LICENSE" | ||
|
||
jobs: | ||
push: | ||
name: Push Stage | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Sync local repo with remote repo | ||
uses: appleboy/ssh-action@master | ||
env: | ||
PROJECT_DIR: ${{ secrets.PROJECT_DIR }} | ||
with: | ||
host: ${{ secrets.SSH_HOSTNAME }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
passphrase: ${{ secrets.SSH_PRIVATE_KEY_PASSPHRASE }} | ||
envs: PROJECT_DIR | ||
script_stop: true | ||
script: | | ||
cd "${PROJECT_DIR}/" | ||
sudo git fetch origin | ||
sudo git reset --hard origin/main | ||
build: | ||
name: Build Stage | ||
needs: push | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Build the latest container(s) | ||
uses: appleboy/ssh-action@master | ||
env: | ||
PROJECT_DIR: ${{ secrets.PROJECT_DIR }} | ||
with: | ||
host: ${{ secrets.SSH_HOSTNAME }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
passphrase: ${{ secrets.SSH_PRIVATE_KEY_PASSPHRASE }} | ||
envs: PROJECT_DIR | ||
script_stop: true | ||
script: | | ||
cd "${PROJECT_DIR}/" | ||
sudo docker compose build | ||
deploy: | ||
name: Deploy Stage | ||
needs: [push, build] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Deploy the latest build(s) | ||
uses: appleboy/ssh-action@master | ||
env: | ||
PROJECT_DIR: ${{ secrets.PROJECT_DIR }} | ||
with: | ||
host: ${{ secrets.SSH_HOSTNAME }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
passphrase: ${{ secrets.SSH_PRIVATE_KEY_PASSPHRASE }} | ||
envs: PROJECT_DIR | ||
script_stop: true | ||
script: | | ||
cd "${PROJECT_DIR}/" | ||
sudo docker compose down | ||
sudo docker compose up -d |