Provision demo1 (tag: data-partition) #240
Workflow file for this run
This file contains hidden or 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: Provision Infrastructure | |
| run-name: "Provision ${{ inputs.environment }} (tag: ${{ inputs.tags }})" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| environment: | |
| description: 'Infrastructure to provision' | |
| required: true | |
| default: 'dev' | |
| type: choice | |
| options: | |
| - "demo1" | |
| tags: | |
| description: 'Tags to apply to the provisioned resources' | |
| required: true | |
| default: all | |
| type: choice | |
| options: | |
| - all | |
| - updates | |
| - users | |
| - backup | |
| - application | |
| - tools | |
| - fail2ban | |
| - data-partition | |
| - decrypt-on-boot | |
| - checks | |
| - containerd-setup | |
| - k8s | |
| - system-preparation | |
| jobs: | |
| approve: | |
| environment: ${{ inputs.environment }} | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 60 | |
| steps: | |
| - name: Waiting for manual approval | |
| if: ${{ (vars.APPROVAL_REQUIRED || 'false') == 'true' }} | |
| uses: trstringer/manual-approval@v1 | |
| with: | |
| secret: ${{ github.TOKEN }} | |
| approvers: ${{ vars.GH_APPROVERS }} | |
| minimum-approvals: 1 | |
| issue-title: > | |
| Deploy (${{ inputs.environment }}): core: ${{ inputs.core-image-tag }} | |
| country config: ${{ inputs.countryconfig-image-tag }} | |
| issue-body: > | |
| Please approve or deny the deployment of core: ${{ inputs.core-image-tag }} | |
| country config: ${{ inputs.countryconfig-image-tag }} to ${{ inputs.environment }} | |
| exclude-workflow-initiator-as-approver: false | |
| provision: | |
| needs: approve | |
| runs-on: | |
| - self-hosted | |
| - ${{ inputs.environment }} | |
| - node | |
| environment: ${{ inputs.environment }} | |
| steps: | |
| - name: Set variables for ansible | |
| id: ansible-variables | |
| run: | | |
| JSON_WITH_NEWLINES=$(cat<<EOF | |
| ${{ toJSON(env) }} | |
| EOF) | |
| JSON_WITHOUT_NEWLINES=$(echo $JSON_WITH_NEWLINES | jq -R -c .) | |
| echo "EXTRA_VARS=$JSON_WITHOUT_NEWLINES" >> $GITHUB_OUTPUT | |
| env: | |
| encrypted_disk_size: ${{ vars.DISK_SPACE }} | |
| disk_encryption_key: ${{ secrets.ENCRYPTION_KEY }} | |
| k8s_runner_token: ${{ secrets.GH_TOKEN }} | |
| repository: ${{ github.repository }} | |
| k8s_cluster_env: ${{ inputs.environment }} | |
| docker_username: ${{ secrets.DOCKER_USERNAME }} | |
| docker_password: ${{ secrets.DOCKER_TOKEN }} | |
| smtp_host: ${{ secrets.SMTP_HOST }} | |
| smtp_port: ${{ secrets.SMTP_PORT }} | |
| smtp_user: ${{ secrets.SMTP_USERNAME }} | |
| smtp_secure: ${{ secrets.SMTP_SECURE }} | |
| # FIXME: Make this field configurable via secrets | |
| smtp_from: "team@opencrvs.org" | |
| smtp_password: ${{ secrets.SMTP_PASSWORD }} | |
| alert_email: ${{ secrets.ALERT_EMAIL }} | |
| - name: checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Run Ansible Playbook | |
| uses: dawidd6/action-ansible-playbook@v4 | |
| env: | |
| ANSIBLE_PERSISTENT_COMMAND_TIMEOUT: 10 | |
| ANSIBLE_SSH_TIMEOUT: 10 | |
| ANSIBLE_SSH_RETRIES: 5 | |
| with: | |
| requirements: galaxy-requirements.yml | |
| playbook: playbook.yml | |
| directory: ./infrastructure/server-setup | |
| # Add --verbose to get more output | |
| options: |- | |
| --inventory inventory/${{ inputs.environment }}.yml | |
| ${{ inputs.tags != 'all' && format('--tags={0}', inputs.tags) || '' }} | |
| --extra-vars ""${{ steps.ansible-variables.outputs.EXTRA_VARS }}"" |