-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: move deployment script to its own file
- Loading branch information
1 parent
58164cc
commit 6f79896
Showing
2 changed files
with
56 additions
and
32 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,38 @@ | ||
name: SSH Deploy Script | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
environment: | ||
required: true | ||
type: string | ||
branch: | ||
required: true | ||
type: string | ||
secrets: | ||
host: | ||
required: true | ||
port: | ||
required: true | ||
key: | ||
required: true | ||
username: | ||
required: true | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
environment: ${{ inputs.environment }} | ||
steps: | ||
- uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.host }} | ||
port: ${{ secrets.port }} | ||
key: ${{ secrets.key }} | ||
username: ${{ secrets.username }} | ||
script: | | ||
cd ${GITHUB_REPOSITORY##*/} | ||
git checkout ${{ inputs.branch }} | ||
git pull | ||
docker compose down | ||
docker compose 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 |
---|---|---|
|
@@ -16,40 +16,26 @@ on: | |
jobs: | ||
deploy-prod: | ||
name: Production | ||
runs-on: ubuntu-latest | ||
environment: Production | ||
if: github.ref == 'refs/heads/main' || (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'Production') | ||
steps: | ||
- name: Executing remote SSH commands using SSH key | ||
uses: appleboy/[email protected] | ||
with: | ||
username: ${{ secrets.USERNAME }} | ||
host: ${{ secrets.HOST }} | ||
key: ${{ secrets.KEY }} | ||
port: ${{ secrets.PORT }} | ||
script: | | ||
cd ${GITHUB_REPOSITORY##*/} | ||
git checkout ${GITHUB_REF##*/} | ||
git pull | ||
docker compose down | ||
docker compose up -d | ||
uses: ./.github/workflows/deploy-script.yml | ||
with: | ||
environment: Production | ||
branch: main | ||
secrets: | ||
host: ${{ secrets.ssh_host }} | ||
port: ${{ secrets.ssh_port }} | ||
key: ${{ secrets.ssh_key }} | ||
username: ${{ secrets.username }} | ||
|
||
deploy-dev: | ||
name: Development | ||
runs-on: ubuntu-latest | ||
environment: Development | ||
if: github.ref == 'refs/heads/dev' || (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'Development') | ||
steps: | ||
- name: Executing remote SSH commands using SSH key | ||
uses: appleboy/[email protected] | ||
with: | ||
username: ${{ secrets.USERNAME }} | ||
host: ${{ secrets.HOST }} | ||
key: ${{ secrets.KEY }} | ||
port: ${{ secrets.PORT }} | ||
script: | | ||
cd ${GITHUB_REPOSITORY##*/} | ||
git checkout ${GITHUB_REF##*/} | ||
git pull | ||
docker compose down | ||
docker compose up -d | ||
uses: ./.github/workflows/deploy-script.yml | ||
with: | ||
environment: Development | ||
branch: dev | ||
secrets: | ||
host: ${{ secrets.ssh_host }} | ||
port: ${{ secrets.ssh_port }} | ||
key: ${{ secrets.ssh_key }} | ||
username: ${{ secrets.username }} |