Skip to content

Manual Deploy

Manual Deploy #19

Workflow file for this run

name: Manual Deploy
on:
workflow_dispatch:
inputs:
environment:
description: Choose environment
options:
- staging
- production
default: staging
type: choice
required: true
targets:
description: Choose target type
options:
- all
- single_host
default: all
type: choice
required: true
host:
description: Host (optional)
type: string
host_ip:
description: Host IP (optional)
type: string
branch:
description: Choose branch (optional)
type: string
default: master
jobs:
deploy:
runs-on: runonflux
steps:
- name: Cancel if values not set
if: "${{ (github.event.inputs.targets == 'single_host') && ! github.event.inputs.host }}"
run: exit 1
- name: Checkout repository
uses: actions/checkout@v5
with:
ref: ${{ github.event.inputs.branch }}
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Install Ansible
run: pip install ansible
# dev hosts should have dns entries
- name: Add temp dev host to /etc/hosts
run: >
sudo bash -c "echo \"${{ github.event.inputs.host_ip }}
${{ github.event.inputs.host }}.runonflux.io\" >>
/etc/hosts"
if: github.event.inputs.host && github.event.inputs.host_ip
- name: Set up SSH key
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
run: echo "$SSH_PRIVATE_KEY" > privatekey && chmod 0400 privatekey
- name: Run Deployment on all hosts
if: ${{ github.event.inputs.targets == 'all' }}
env:
MAXMIND_ACCOUNT_ID: ${{ secrets.MAXMIND_ACCOUNT_ID }}
MAXMIND_LICENSE_KEY: ${{ secrets.MAXMIND_LICENSE_KEY }}
TSIG_STAGING_ZONE_TRANSFER_KEY: ${{ secrets.TSIG_STAGING_ZONE_TRANSFER_KEY }}
TSIG_PRODUCTION_ZONE_TRANSFER_KEY: ${{ secrets.TSIG_PRODUCTION_ZONE_TRANSFER_KEY }}
PDNS_API_STAGING_KEY: ${{ secrets.PDNS_API_STAGING_KEY }}
PDNS_API_PRODUCTION_KEY: ${{ secrets.PDNS_API_PRODUCTION_KEY }}
run: |
ansible-playbook -i hosts.yaml \
-e "DEPLOY_ENV=${{ github.event.inputs.environment }}" \
-e "maxmind_account_id=$MAXMIND_ACCOUNT_ID" \
-e "maxmind_license_key=$MAXMIND_LICENSE_KEY" \
-e "tsig_staging_zone_transfer_key=$TSIG_STAGING_ZONE_TRANSFER_KEY" \
-e "tsig_production_zone_transfer_key=$TSIG_PRODUCTION_ZONE_TRANSFER_KEY" \
-e "pdns_api_staging_key=$PDNS_API_STAGING_KEY" \
-e "pdns_api_production_key=$PDNS_API_PRODUCTION_KEY" \
powerdns_setup.yaml
- name: Run Deployment on single host
if: ${{ github.event.inputs.targets == 'single_host' }}
env:
MAXMIND_ACCOUNT_ID: ${{ secrets.MAXMIND_ACCOUNT_ID }}
MAXMIND_LICENSE_KEY: ${{ secrets.MAXMIND_LICENSE_KEY }}
TSIG_STAGING_ZONE_TRANSFER_KEY: ${{ secrets.TSIG_STAGING_ZONE_TRANSFER_KEY }}
TSIG_PRODUCTION_ZONE_TRANSFER_KEY: ${{ secrets.TSIG_PRODUCTION_ZONE_TRANSFER_KEY }}
PDNS_API_STAGING_KEY: ${{ secrets.PDNS_API_STAGING_KEY }}
PDNS_API_PRODUCTION_KEY: ${{ secrets.PDNS_API_PRODUCTION_KEY }}
run: |
ansible-playbook -i hosts.yaml \
--limit ${{ github.event.inputs.host }} \
-e "DEPLOY_ENV=${{ github.event.inputs.environment }}" \
-e "maxmind_account_id=$MAXMIND_ACCOUNT_ID" \
-e "maxmind_license_key=$MAXMIND_LICENSE_KEY" \
-e "tsig_staging_zone_transfer_key=$TSIG_STAGING_ZONE_TRANSFER_KEY" \
-e "tsig_production_zone_transfer_key=$TSIG_PRODUCTION_ZONE_TRANSFER_KEY" \
-e "pdns_api_staging_key=$PDNS_API_STAGING_KEY" \
-e "pdns_api_production_key=$PDNS_API_PRODUCTION_KEY" \
powerdns_setup.yaml