Skip to content

Commit

Permalink
devops: Generate deployment workflow for jo
Browse files Browse the repository at this point in the history
  • Loading branch information
jhf committed Jan 10, 2025
1 parent d7b453e commit 4af7bcb
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 14 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/deploy-to-jo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: "jo.statbus.org<-devops/deploy-to-jo"
on:
# Allow manual deployment in github
workflow_dispatch:
push:
branches:
- "devops/deploy-to-jo"

# Deploys are serial for a deploy branch.
concurrency:
group: ${{ github.ref_name }}
cancel-in-progress: false

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands
uses: appleboy/[email protected]
with:
host: niue.statbus.org
username: statbus_jo
key: ${{ secrets.SSH_KEY }}
command_timeout: 60m
script: /usr/local/bin/deploy-statbus.sh
42 changes: 28 additions & 14 deletions devops/create-new-statbus-installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,34 @@ for subdomain in "" "api." "www."; do
fi
done

# Generate GitHub workflow file for deployment if it doesn't exist
if [ ! -f ".github/workflows/master-to-${DEPLOYMENT_SLOT_CODE}.yaml" ]; then
echo "Generating GitHub workflow file..."
if [ -f ".github/workflows/master-to-demo.yaml" ]; then
mkdir -p .github/workflows
sed "s/demo/${DEPLOYMENT_SLOT_CODE}/g" .github/workflows/master-to-demo.yaml > ".github/workflows/master-to-${DEPLOYMENT_SLOT_CODE}.yaml"
echo "Created GitHub workflow file for ${DEPLOYMENT_SLOT_CODE}"
else
echo "Warning: Could not find template workflow file .github/workflows/master-to-demo.yaml"
fi
else
echo "GitHub workflow file for ${DEPLOYMENT_SLOT_CODE} already exists"
fi

# Generate deploy-to workflow file if it doesn't exist
if [ ! -f ".github/workflows/deploy-to-${DEPLOYMENT_SLOT_CODE}.yaml" ]; then
echo "Generating deploy-to workflow file..."
if [ -f ".github/workflows/deploy-to-demo.yaml" ]; then
mkdir -p .github/workflows
sed "s/demo/${DEPLOYMENT_SLOT_CODE}/g" .github/workflows/deploy-to-demo.yaml > ".github/workflows/deploy-to-${DEPLOYMENT_SLOT_CODE}.yaml"
echo "Created deploy-to workflow file for ${DEPLOYMENT_SLOT_CODE}"
else
echo "Warning: Could not find template workflow file .github/workflows/deploy-to-demo.yaml"
fi
else
echo "Deploy-to workflow file for ${DEPLOYMENT_SLOT_CODE} already exists"
fi

echo "Configuring server..."

echo "Creating user"
Expand Down Expand Up @@ -270,18 +298,4 @@ ssh $DEPLOYMENT_USER@$HOST bash <<START_STATBUS
./devops/manage-statbus.sh create-users
START_STATBUS

# Generate GitHub workflow file for deployment if it doesn't exist
if [ ! -f ".github/workflows/master-to-${DEPLOYMENT_SLOT_CODE}.yaml" ]; then
echo "Generating GitHub workflow file..."
if [ -f ".github/workflows/master-to-demo.yaml" ]; then
mkdir -p .github/workflows
sed "s/demo/${DEPLOYMENT_SLOT_CODE}/g" .github/workflows/master-to-demo.yaml > ".github/workflows/master-to-${DEPLOYMENT_SLOT_CODE}.yaml"
echo "Created GitHub workflow file for ${DEPLOYMENT_SLOT_CODE}"
else
echo "Warning: Could not find template workflow file .github/workflows/master-to-demo.yaml"
fi
else
echo "GitHub workflow file for ${DEPLOYMENT_SLOT_CODE} already exists"
fi

echo "Setup of ${DEPLOYMENT_SLOT_NAME}(${DEPLOYMENT_SLOT_CODE}) completed successfully!"

0 comments on commit 4af7bcb

Please sign in to comment.