Skip to content

Ansible deploy production #211

Ansible deploy production

Ansible deploy production #211

Workflow file for this run

name: Ansible deploy production
on:
# workflow_run:
# workflows:
# - "Build and deploy Docker images"
# types:
# - completed
workflow_dispatch:
inputs:
tag:
description: Git tag to deploy against
required: true
jobs:
deployment:
runs-on: ubuntu-latest
environment:
name: production
url: https://stylo.huma-num.fr
if: ${{ (github.event.workflow_run.conclusion == 'success' && github.ref_type == 'tag') || github.event_name == 'workflow_dispatch' }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}
- name: Set up Python 3.10 (w/ cache)
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: '**/deploy-requirements.txt'
- name: Install dependencies
run: |
python -m pip install -r .github/workflows/deploy-requirements.txt
- name: Set Ansible config secrets
run: |
echo "${{ secrets.ANSIBLE_VAULT_PASSWORD_PROD }}" > infrastructure/.ansible-vault-password
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY_PROD }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
- name: Run playbook
working-directory: ./infrastructure
run: ansible-playbook -i inventories/prod --extra-vars "@vault-prod.yml" --extra-vars "app_version=${{ inputs.tag }}" --private-key ~/.ssh/id_ed25519 --vault-password-file ./.ansible-vault-password playbook.yml -v