-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allows for deployments to occur directly from GitHub Actions. This happens by running a bash script on the remote server that deploys the Discord bot. This creates an easier to use interface with a log for bot deployments. This also creates a pipeline that updates staging directly on push.
- Loading branch information
1 parent
a02f089
commit 6cb3187
Showing
3 changed files
with
121 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,26 @@ | ||
name: Deploy Production | ||
|
||
run-name: ${{ github.actor }} is deploying Gamebot to production | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
branch: | ||
type: string | ||
default: master | ||
required: false | ||
|
||
jobs: | ||
deploy-staging: | ||
uses: ./.github/workflows/deploy-staging.yml | ||
with: | ||
branch: master | ||
secrets: inherit | ||
deploy: | ||
needs: deploy-staging | ||
uses: ./.github/workflows/deploy.yml | ||
with: | ||
environment: production | ||
log_level: info | ||
branch: master | ||
secrets: inherit |
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,47 @@ | ||
name: Deploy Staging | ||
|
||
run-name: ${{ github.actor }} is deploying Gamebot to staging | ||
|
||
on: | ||
# Allow for automatic deployment on branches that aren't concerned about downtime | ||
push: | ||
branches: | ||
- staging | ||
workflow_dispatch: | ||
inputs: | ||
branch: | ||
type: string | ||
default: staging | ||
required: false | ||
log_level: | ||
description: 'Log level' | ||
type: choice | ||
options: | ||
- trace | ||
- debug | ||
- info | ||
- warn | ||
- error | ||
default: info | ||
required: false | ||
# Workflow calls allow for this action to be called by other actions | ||
workflow_call: | ||
inputs: | ||
branch: | ||
type: string | ||
default: staging | ||
required: false | ||
log_level: | ||
description: 'Log level' | ||
type: string | ||
default: info | ||
required: false | ||
|
||
jobs: | ||
deploy: | ||
uses: ./.github/workflows/deploy.yml | ||
with: | ||
environment: staging | ||
log_level: ${{ inputs.log_level }} | ||
branch: ${{ inputs.branch }} | ||
secrets: inherit |
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,48 @@ | ||
name: deploy | ||
|
||
run-name: ${{ github.actor }} is deploying Gamebot | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
environment: | ||
description: 'Deployment environment' | ||
type: string | ||
required: true | ||
log_level: | ||
description: 'Log level' | ||
type: string | ||
default: 'info' | ||
required: false | ||
branch: | ||
description: 'Branch to deploy from' | ||
type: string | ||
required: false | ||
|
||
jobs: | ||
run-unit-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." | ||
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" | ||
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." | ||
- name: Check out repository code | ||
uses: actions/checkout@v3 | ||
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." | ||
- run: echo "🖥️ The workflow is now ready to test your code on the runner." | ||
- name: List files in the repository | ||
run: | | ||
ls ${{ github.workspace }} | ||
- run: echo "🍏 This job's status is ${{ job.status }}." | ||
run-deployment: | ||
needs: run-unit-tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Run deployment script | ||
uses: appleboy/ssh-action@v1.0.0 | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USER }} | ||
port: 22 | ||
key: ${{ secrets.SSH_KEY }} | ||
script: /home/ubuntu/deploy/bot.sh -e ${{ inputs.environment }} -b ${{ inputs.branch }} |