Deploy Server #16
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
name: Deploy Server | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "Run number to deploy" | |
required: true | |
default: "latest" | |
type: string | |
environment: | |
description: "Environment to deploy to" | |
required: true | |
type: choice | |
default: "production" | |
options: | |
- "production" | |
- "test" | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Extract branch name | |
shell: bash | |
run: | | |
branch_name="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" | |
branch_name=$(echo "$branch_name" | sed 's/\//_/g') | |
echo "branch=${branch_name}" >> $GITHUB_OUTPUT | |
id: extract_branch | |
- uses: actions/checkout@v4 | |
- name: Deploy to server | |
uses: easingthemes/ssh-deploy@main | |
with: | |
SSH_PRIVATE_KEY: ${{ secrets.BLUMY_KEY }} | |
ARGS: "-rlgoDzvc -i" | |
SOURCE: "Server/docker-compose.yml" | |
REMOTE_HOST: ${{ secrets.BLUMY_HOST }} | |
REMOTE_USER: ${{ secrets.BLUMY_USER }} | |
TARGET: ${{ github.event.inputs.environment == 'production' && secrets.BLUMY_HOST_PATH || secrets.BLUMY_TEST_HOST_PATH }}/ | |
SCRIPT_BEFORE: | | |
echo "Nothing to do before deploy" | |
SCRIPT_AFTER: | | |
echo "Deploying with Docker Compose" | |
cd ${{ github.event.inputs.environment == 'production' && secrets.BLUMY_HOST_PATH || secrets.BLUMY_TEST_HOST_PATH }} | |
echo "setting IMAGE_BRANCH to ${{ steps.extract_branch.outputs.branch }}" | |
export IMAGE_BRANCH=${{ steps.extract_branch.outputs.branch }} | |
echo "setting IMAGE_NUMBER to ${{ github.event.inputs.version }}" | |
export IMAGE_NUMBER=${{ github.event.inputs.version }} | |
echo "Running Docker Compose" | |
docker compose pull | |
docker compose up -d | |
echo "Deployment complete" |