-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #358 from hngprojects/migration-patch
Create and update workflow files
- Loading branch information
Showing
9 changed files
with
251 additions
and
1 deletion.
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,83 @@ | ||
name: Build, Test, and Deploy for Development | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev | ||
|
||
jobs: | ||
build_and_upload_artifact: | ||
runs-on: ubuntu-latest | ||
if: github.event.repository.fork == false | ||
environment: development | ||
env: | ||
SSH_USERNAME: ${{ secrets.SSH_USERNAME }} | ||
SSH_HOST: ${{ secrets.SSH_HOST }} | ||
SSH_PORT: ${{ secrets.SSH_PORT }} | ||
SSH_KEY: ${{ secrets.SSH_KEY }} | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
- name: Set Golang | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.22.1" | ||
- name: Create app config file | ||
run: cp app-sample.env app.env | ||
- name: Build the application | ||
run: go build -o development_app | ||
|
||
- name: Create app.env file | ||
uses: vicradon/[email protected] | ||
with: | ||
action_input_file: "app-sample.env" | ||
action_output_file: "app.env" | ||
action_true_string_variables: | | ||
MAIL_PASSWORD | ||
SERVER_PORT: ${{ secrets.SERVER_PORT }} | ||
DB_NAME: ${{ secrets.DB_NAME }} | ||
USERNAME: ${{ secrets.USERNAME }} | ||
APP_NAME: "development" | ||
APP_URL: ${{ vars.URL}} | ||
REDIS_PORT: ${{ secrets.REDIS_PORT }} | ||
MAIL_SERVER: ${{ secrets.MAIL_SERVER }} | ||
MAIL_USERNAME: ${{ secrets.MAIL_USERNAME }} | ||
MAIL_PASSWORD: ${{ secrets.MAIL_PASSWORD }} | ||
MAIL_PORT: ${{ secrets.MAIL_PORT }} | ||
MIGRATE: "true" | ||
|
||
- name: Copy artifacts to server | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ env.SSH_HOST }} | ||
username: ${{ env.SSH_USERNAME }} | ||
password: ${{ env.SSH_PASSWORD }} | ||
port: ${{ env.SSH_PORT }} | ||
source: "app.env,development_app" | ||
target: ~/deployments/development | ||
|
||
restart_app: | ||
runs-on: ubuntu-latest | ||
needs: build_and_upload_artifact | ||
environment: development | ||
env: | ||
SSH_USERNAME: ${{ secrets.SSH_USERNAME }} | ||
SSH_HOST: ${{ secrets.SSH_HOST }} | ||
SSH_PORT: ${{ secrets.SSH_PORT }} | ||
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }} | ||
|
||
steps: | ||
- name: SSH into server and deploy | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ env.SSH_HOST }} | ||
username: ${{ env.SSH_USERNAME }} | ||
password: ${{ env.SSH_PASSWORD }} | ||
port: ${{ env.SSH_PORT }} | ||
script: | | ||
mkdir -p ~/deployments/development | ||
cd ~/deployments/development | ||
git reset --hard | ||
git pull origin dev | ||
pm2 restart development_app |
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,83 @@ | ||
name: Build, Test, and Deploy for Production | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build_and_upload_artifact: | ||
runs-on: ubuntu-latest | ||
if: github.event.repository.fork == false | ||
environment: production | ||
env: | ||
SSH_USERNAME: ${{ secrets.SSH_USERNAME }} | ||
SSH_HOST: ${{ secrets.SSH_HOST }} | ||
SSH_PORT: ${{ secrets.SSH_PORT }} | ||
SSH_KEY: ${{ secrets.SSH_KEY }} | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
- name: Set Golang | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.22.1" | ||
- name: Create app config file | ||
run: cp app-sample.env app.env | ||
- name: Build the application | ||
run: go build -o production_app | ||
|
||
- name: Create app.env file | ||
uses: vicradon/[email protected] | ||
with: | ||
action_input_file: "app-sample.env" | ||
action_output_file: "app.env" | ||
action_true_string_variables: | | ||
MAIL_PASSWORD | ||
SERVER_PORT: ${{ secrets.SERVER_PORT }} | ||
DB_NAME: ${{ secrets.DB_NAME }} | ||
USERNAME: ${{ secrets.USERNAME }} | ||
APP_NAME: "production" | ||
APP_URL: ${{ vars.URL}} | ||
REDIS_PORT: ${{ secrets.REDIS_PORT }} | ||
MAIL_SERVER: ${{ secrets.MAIL_SERVER }} | ||
MAIL_USERNAME: ${{ secrets.MAIL_USERNAME }} | ||
MAIL_PASSWORD: ${{ secrets.MAIL_PASSWORD }} | ||
MAIL_PORT: ${{ secrets.MAIL_PORT }} | ||
MIGRATE: "true" | ||
|
||
- name: Copy artifacts to server | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ env.SSH_HOST }} | ||
username: ${{ env.SSH_USERNAME }} | ||
password: ${{ env.SSH_PASSWORD }} | ||
port: ${{ env.SSH_PORT }} | ||
source: "app.env,production_app" | ||
target: ~/deployments/production | ||
|
||
restart_app: | ||
runs-on: ubuntu-latest | ||
needs: build_and_upload_artifact | ||
environment: production | ||
env: | ||
SSH_USERNAME: ${{ secrets.SSH_USERNAME }} | ||
SSH_HOST: ${{ secrets.SSH_HOST }} | ||
SSH_PORT: ${{ secrets.SSH_PORT }} | ||
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }} | ||
|
||
steps: | ||
- name: SSH into server and deploy | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ env.SSH_HOST }} | ||
username: ${{ env.SSH_USERNAME }} | ||
password: ${{ env.SSH_PASSWORD }} | ||
port: ${{ env.SSH_PORT }} | ||
script: | | ||
mkdir -p ~/deployments/production | ||
cd ~/deployments/production | ||
git reset --hard | ||
git pull origin main | ||
pm2 restart production_app |
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,83 @@ | ||
name: Build, Test, and Deploy for Staging | ||
|
||
on: | ||
push: | ||
branches: | ||
- staging | ||
|
||
jobs: | ||
build_and_upload_artifact: | ||
runs-on: ubuntu-latest | ||
if: github.event.repository.fork == false | ||
environment: staging | ||
env: | ||
SSH_USERNAME: ${{ secrets.SSH_USERNAME }} | ||
SSH_HOST: ${{ secrets.SSH_HOST }} | ||
SSH_PORT: ${{ secrets.SSH_PORT }} | ||
SSH_KEY: ${{ secrets.SSH_KEY }} | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
- name: Set Golang | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.22.1" | ||
- name: Create app config file | ||
run: cp app-sample.env app.env | ||
- name: Build the application | ||
run: go build -o staging_app | ||
|
||
- name: Create app.env file | ||
uses: vicradon/[email protected] | ||
with: | ||
action_input_file: "app-sample.env" | ||
action_output_file: "app.env" | ||
action_true_string_variables: | | ||
MAIL_PASSWORD | ||
SERVER_PORT: ${{ secrets.SERVER_PORT }} | ||
DB_NAME: ${{ secrets.DB_NAME }} | ||
USERNAME: ${{ secrets.USERNAME }} | ||
APP_NAME: "staging" | ||
APP_URL: ${{ vars.URL}} | ||
REDIS_PORT: ${{ secrets.REDIS_PORT }} | ||
MAIL_SERVER: ${{ secrets.MAIL_SERVER }} | ||
MAIL_USERNAME: ${{ secrets.MAIL_USERNAME }} | ||
MAIL_PASSWORD: ${{ secrets.MAIL_PASSWORD }} | ||
MAIL_PORT: ${{ secrets.MAIL_PORT }} | ||
MIGRATE: "true" | ||
|
||
- name: Copy artifacts to server | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ env.SSH_HOST }} | ||
username: ${{ env.SSH_USERNAME }} | ||
password: ${{ env.SSH_PASSWORD }} | ||
port: ${{ env.SSH_PORT }} | ||
source: "app.env,staging_app" | ||
target: ~/deployments/staging | ||
|
||
restart_app: | ||
runs-on: ubuntu-latest | ||
needs: build_and_upload_artifact | ||
environment: staging | ||
env: | ||
SSH_USERNAME: ${{ secrets.SSH_USERNAME }} | ||
SSH_HOST: ${{ secrets.SSH_HOST }} | ||
SSH_PORT: ${{ secrets.SSH_PORT }} | ||
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }} | ||
|
||
steps: | ||
- name: SSH into server and deploy | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ env.SSH_HOST }} | ||
username: ${{ env.SSH_USERNAME }} | ||
password: ${{ env.SSH_PASSWORD }} | ||
port: ${{ env.SSH_PORT }} | ||
script: | | ||
mkdir -p ~/deployments/staging | ||
cd ~/deployments/staging | ||
git reset --hard | ||
git pull origin staging | ||
pm2 restart staging_app |
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 |
---|---|---|
|
@@ -34,4 +34,5 @@ app.env | |
|
||
development_app | ||
staging_app | ||
production_app | ||
production_app | ||
.DS_Store |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.