-
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.
- Loading branch information
Showing
15 changed files
with
433 additions
and
86 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,72 @@ | ||
name: Dev Deployment | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- dev | ||
|
||
jobs: | ||
build_docker_image: | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'push' | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Build Docker image | ||
run: docker build -t golang_dev . | ||
- name: Save and compress Docker image | ||
run: docker save golang_dev | gzip > golang_dev.tar.gz | ||
- name: Upload Docker image | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: golang_dev | ||
path: golang_dev.tar.gz | ||
|
||
upload_docker_image: | ||
runs-on: ubuntu-latest | ||
needs: build_docker_image | ||
if: github.event.repository.fork == false | ||
environment: | ||
name: "development" | ||
url: ${{ vars.URL }} | ||
steps: | ||
- name: Download Docker image | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: golang_dev | ||
path: . | ||
|
||
- name: Copy image to server | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
password: ${{ secrets.SSH_PASSWORD }} | ||
source: golang_dev.tar.gz | ||
target: "/tmp" | ||
|
||
run_docker_container: | ||
runs-on: ubuntu-latest | ||
needs: upload_docker_image | ||
if: github.event.repository.fork == false | ||
environment: development | ||
env: | ||
SSH_USERNAME: ${{ secrets.SSH_USERNAME }} | ||
SSH_HOST: ${{ secrets.SSH_HOST }} | ||
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }} | ||
|
||
steps: | ||
- name: Deploy on server | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ env.HOST }} | ||
username: ${{ env.USERNAME }} | ||
password: ${{ env.PASSWORD }} | ||
script: | | ||
gunzip -c /tmp/golang_dev.tar.gz | docker load | ||
rm -f /tmp/golang_dev.tar.gz | ||
cd ~/deployments/development | ||
git reset --hard | ||
git pull origin dev | ||
docker compose -f docker-compose.yml up -d |
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 |
---|---|---|
@@ -1,9 +1,6 @@ | ||
name: Build, Test, and Deploy for Development | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev | ||
pull_request: | ||
branches: | ||
- dev | ||
|
@@ -158,27 +155,3 @@ jobs: | |
MAIL_PASSWORD=${{ secrets.MAIL_PASSWORD }} \ | ||
MAIL_PORT=${{ secrets.MAIL_PORT }} \ | ||
MIGRATE=true | ||
run_docker_container: | ||
runs-on: ubuntu-latest | ||
needs: upload_docker_image | ||
if: github.event.repository.fork == false && github.event_name == 'push' | ||
environment: development | ||
env: | ||
SSH_USERNAME: ${{ secrets.SSH_USERNAME }} | ||
SSH_HOST: ${{ secrets.SSH_HOST }} | ||
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }} | ||
|
||
steps: | ||
- name: Deploy on server | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ env.HOST }} | ||
username: ${{ env.USERNAME }} | ||
password: ${{ env.PASSWORD }} | ||
script: | | ||
gunzip -c /tmp/golang_dev.tar.gz | docker load | ||
rm -f /tmp/golang_dev.tar.gz | ||
cd ~/deployments/development | ||
docker compose -f docker-compose-development.yml up -d |
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,40 @@ | ||
name: PR Deploy for Development | ||
on: | ||
pull_request: | ||
branches: [dev] | ||
types: [opened, synchronize, reopened, closed] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
deploy-pr: | ||
environment: | ||
name: development | ||
# url: ${{ steps.deploy.outputs.preview-url }} | ||
runs-on: ubuntu-latest | ||
env: | ||
SSH_USERNAME: ${{ secrets.SSH_USERNAME }} | ||
SSH_HOST: ${{ secrets.SSH_HOST }} | ||
SSH_PORT: ${{ secrets.SSH_PORT }} | ||
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }} | ||
|
||
steps: | ||
- name: Checkout to branch | ||
uses: actions/checkout@v4 | ||
- id: deploy | ||
name: Pull Request Deploy | ||
uses: hngprojects/pr-deploy@dev | ||
with: | ||
server_host: ${{ env.SSH_HOST }} | ||
server_username: ${{ env.SSH_USERNAME }} | ||
server_password: ${{ env.SSH_PASSWORD }} | ||
server_port: ${{ env.SSH_PORT }} | ||
comment: true | ||
context: '.' | ||
dockerfile: 'Dockerfile' | ||
exposed_port: '8019' | ||
# host_volume_path: '/var/' | ||
# container_volume_path: '/var/' | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Print Preview Url | ||
run: | | ||
echo "Preview Url: ${{ steps.deploy.outputs.preview-url }}" |
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
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,40 @@ | ||
name: PR Deploy for Production | ||
on: | ||
pull_request: | ||
branches: [main] | ||
types: [opened, synchronize, reopened, closed] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
deploy-pr: | ||
environment: | ||
name: production | ||
# url: ${{ steps.deploy.outputs.preview-url }} | ||
runs-on: ubuntu-latest | ||
env: | ||
SSH_USERNAME: ${{ secrets.SSH_USERNAME }} | ||
SSH_HOST: ${{ secrets.SSH_HOST }} | ||
SSH_PORT: ${{ secrets.SSH_PORT }} | ||
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }} | ||
|
||
steps: | ||
- name: Checkout to branch | ||
uses: actions/checkout@v4 | ||
- id: deploy | ||
name: Pull Request Deploy | ||
uses: hngprojects/pr-deploy@main | ||
with: | ||
server_host: ${{ env.SSH_HOST }} | ||
server_username: ${{ env.SSH_USERNAME }} | ||
server_password: ${{ env.SSH_PASSWORD }} | ||
server_port: ${{ env.SSH_PORT }} | ||
comment: true | ||
context: '.' | ||
dockerfile: 'Dockerfile' | ||
exposed_port: '8019' | ||
# host_volume_path: '/var/' | ||
# container_volume_path: '/var/' | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Print Preview Url | ||
run: | | ||
echo "Preview Url: ${{ steps.deploy.outputs.preview-url }}" |
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
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
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
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
Oops, something went wrong.