Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: set the deploy job to run only on push #95

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions .github/workflows/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,8 @@ on:
- dev

jobs:
build:
build_and_test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set Golang
uses: actions/setup-go@v4
with:
go-version: "1.22.1"
- name: Build the application
run: go build -o development_app

test:
runs-on: ubuntu-latest
needs: build
env:
TEST_USERNAME: postgres
TEST_PASSWORD: password
Expand All @@ -46,14 +33,27 @@ jobs:
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: Run the application
run: nohup ./development_app > /dev/null 2>&1 &
- name: Wait for application to start
run: sleep 30s
- name: Test for reachability
run: curl http://localhost:8019
- name: Run All Tests
run: go test ./... -timeout 99999s

deploy:
runs-on: ubuntu-latest
needs: test
needs: build_and_test
if: github.event_name == 'push'
env:
SSH_USERNAME: ${{ secrets.SSH_USERNAME }}
SSH_HOST: ${{ secrets.SSH_HOST }}
Expand Down Expand Up @@ -87,4 +87,4 @@ jobs:
git clone -b dev https://github.com/${{ github.repository}} . || { echo "Failed to clone repository"; exit 1; }
fi

bash ./scripts/deploy_app.sh development https://github.com/${{ github.repository}} SERVER_PORT=${{ env.SERVER_PORT }} DB_NAME=${{ env.DB_NAME }} USERNAME=${{ env.USERNAME }} APP_NAME=${{ env.APP_NAME }} APP_URL=${{ env.APP_URL }}
bash ./scripts/deploy_app.sh development https://github.com/${{ github.repository}} SERVER_PORT=${{ env.SERVER_PORT }} DB_NAME=${{ env.DB_NAME }} USERNAME=${{ env.USERNAME }} APP_NAME=${{ env.APP_NAME }} APP_URL=${{ env.APP_URL }} MIGRATE=true
32 changes: 16 additions & 16 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,8 @@ on:
- main

jobs:
build:
build_and_test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set Golang
uses: actions/setup-go@v4
with:
go-version: "1.22.1"
- name: Build the application
run: go build -o production_app

test:
runs-on: ubuntu-latest
needs: build
env:
TEST_USERNAME: postgres
TEST_PASSWORD: password
Expand All @@ -46,14 +33,27 @@ jobs:
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: Run the application
run: nohup ./production_app > /dev/null 2>&1 &
- name: Wait for application to start
run: sleep 30s
- name: Test for reachability
run: curl http://localhost:8019
- name: Run All Tests
run: go test ./... -timeout 99999s

deploy:
runs-on: ubuntu-latest
needs: test
needs: build_and_test
if: github.event_name == 'push'
env:
SSH_USERNAME: ${{ secrets.SSH_USERNAME }}
SSH_HOST: ${{ secrets.SSH_HOST }}
Expand Down Expand Up @@ -87,4 +87,4 @@ jobs:
git clone -b main https://github.com/${{ github.repository}} . || { echo "Failed to clone repository"; exit 1; }
fi

bash ./scripts/deploy_app.sh production https://github.com/${{ github.repository}} SERVER_PORT=${{ env.SERVER_PORT }} DB_NAME=${{ env.DB_NAME }} USERNAME=${{ env.USERNAME }} APP_NAME=${{ env.APP_NAME }} APP_URL=${{ env.APP_URL }}
bash ./scripts/deploy_app.sh production https://github.com/${{ github.repository}} SERVER_PORT=${{ env.SERVER_PORT }} DB_NAME=${{ env.DB_NAME }} USERNAME=${{ env.USERNAME }} APP_NAME=${{ env.APP_NAME }} APP_URL=${{ env.APP_URL }} MIGRATE=true
32 changes: 16 additions & 16 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,8 @@ on:
- staging

jobs:
build:
build_and_test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set Golang
uses: actions/setup-go@v4
with:
go-version: "1.22.1"
- name: Build the application
run: go build -o staging_app

test:
runs-on: ubuntu-latest
needs: build
env:
TEST_USERNAME: postgres
TEST_PASSWORD: password
Expand All @@ -46,14 +33,27 @@ jobs:
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: Run the application
run: nohup ./staging_app > /dev/null 2>&1 &
- name: Wait for application to start
run: sleep 30s
- name: Test for reachability
run: curl http://localhost:8019
- name: Run All Tests
run: go test ./... -timeout 99999s

deploy:
runs-on: ubuntu-latest
needs: test
needs: build_and_test
if: github.event_name == 'push'
env:
SSH_USERNAME: ${{ secrets.SSH_USERNAME }}
SSH_HOST: ${{ secrets.SSH_HOST }}
Expand Down Expand Up @@ -87,4 +87,4 @@ jobs:
git clone -b staging https://github.com/${{ github.repository}} . || { echo "Failed to clone repository"; exit 1; }
fi

bash ./scripts/deploy_app.sh staging https://github.com/${{ github.repository}} SERVER_PORT=${{ env.SERVER_PORT }} DB_NAME=${{ env.DB_NAME }} USERNAME=${{ env.USERNAME }} APP_NAME=${{ env.APP_NAME }} APP_URL=${{ env.APP_URL }}
bash ./scripts/deploy_app.sh staging https://github.com/${{ github.repository}} SERVER_PORT=${{ env.SERVER_PORT }} DB_NAME=${{ env.DB_NAME }} USERNAME=${{ env.USERNAME }} APP_NAME=${{ env.APP_NAME }} APP_URL=${{ env.APP_URL }} MIGRATE=true
2 changes: 1 addition & 1 deletion app-sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ SSLMODE=disable
USERNAME=postgres
PASSWORD=password
DB_NAME=db_name
MIGRATE=true
MIGRATE=false

# Test #
TEST_DB_HOST=localhost
Expand Down
Loading