Deploy #38
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: Deploy | |
concurrency: | |
group: production | |
on: | |
workflow_dispatch: | |
jobs: | |
deployment: | |
runs-on: ubuntu-latest | |
environment: | |
name: production | |
url: https://pix.cloud.ut.ee/ | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
submodules: true | |
- name: Set up Ansible | |
run: | | |
sudo apt-get update | |
sudo apt-get install --only-upgrade openssl | |
sudo apt-get install -y python3-pip | |
pip3 install -U pip ansible pyyaml | |
ansible --version | |
docker --version | |
- name: Set known hosts | |
id: known_hosts | |
run: | | |
echo "::set-output name=server1::$(ssh-keyscan -t rsa,ecdsa,ed25519 193.40.11.243)" | |
echo "::set-output name=server2::$(ssh-keyscan -t rsa,ecdsa,ed25519 193.40.11.123)" | |
echo "::set-output name=server3::$(ssh-keyscan -t rsa,ecdsa,ed25519 193.40.11.119)" | |
- name: Install SSH key | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: "${{ secrets.PIX_SSH_KEY }}" | |
name: "pix" | |
known_hosts: | | |
${{ steps.known_hosts.outputs.server1 }} | |
${{ steps.known_hosts.outputs.server2 }} | |
${{ steps.known_hosts.outputs.server3 }} | |
- name: Unpack secrets to "./secrets/" | |
run: | | |
echo "${{ secrets.SECRETS_TAR_GZ_B64 }}" | base64 -d | tar xz | |
echo "SECRETS_DIR=`pwd`/secrets" >> $GITHUB_ENV | |
- name: Deploy with Ansible | |
env: | |
SECRETS_DIR: ${{ env.SECRETS_DIR }} | |
run: | | |
ansible-playbook -i ansible/hosts.yaml --private-key ~/.ssh/pix ansible/deploy.yaml --extra-vars "secrets_dir=${{ env.SECRETS_DIR }}" |