Ansible deploy dev #614
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: Ansible deploy dev | |
on: | |
workflow_run: | |
workflows: | |
- "Build and deploy Docker images" | |
branches: | |
- main | |
- master | |
types: | |
- completed | |
workflow_dispatch: | |
jobs: | |
deployment: | |
runs-on: ubuntu-latest | |
environment: | |
name: staging | |
url: https://stylo-dev.huma-num.fr | |
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} | |
steps: | |
- uses: actions/checkout@v3 | |
- 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_DEV }}" > infrastructure/.ansible-vault-password | |
- name: Setup SSH | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.SSH_PRIVATE_KEY_DEV }}" > ~/.ssh/id_ed25519 | |
chmod 600 ~/.ssh/id_ed25519 | |
- name: Run playbook | |
working-directory: ./infrastructure | |
run: ansible-playbook -i inventories/dev --extra-vars "@vault-dev.yml" --private-key ~/.ssh/id_ed25519 --vault-password-file ./.ansible-vault-password playbook.yml -vvv |