From 894785fb5c42b88eae7131fa75be29b91027813c Mon Sep 17 00:00:00 2001 From: Julian Schacher Date: Wed, 7 Feb 2024 20:49:43 +0100 Subject: [PATCH] Add GitHub Actions Workflow for maintaining & deploying production hosts The workflow runs on a schedule and can also be triggered manually. --- .../workflows/deploy-production-hosts.yaml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/deploy-production-hosts.yaml diff --git a/.github/workflows/deploy-production-hosts.yaml b/.github/workflows/deploy-production-hosts.yaml new file mode 100644 index 0000000..bb8fa55 --- /dev/null +++ b/.github/workflows/deploy-production-hosts.yaml @@ -0,0 +1,24 @@ +name: Maintain & Deploy Production Hosts +on: + schedule: + # Run Wednesday and Friday (the days on which I (Julian) usually work) at + # 04:00. + - cron: "0 4 * * 3,5" + workflow_dispatch: +jobs: + Run-Everything-Playbook: + runs-on: ubuntu-latest + steps: + - name: Check out repo + uses: actions/checkout@v4 + - name: Setup .ssh + run: | + mkdir -p $HOME/.ssh + chmod 700 $HOME/.ssh + echo "${{ secrets.ANSIBLE_INFRA_SSH_DEPLOY_KEY }}" > $HOME/.ssh/id_ed25519 + chmod 400 $HOME/.ssh/id_ed25519 + echo "${{ vars.ANSIBLE_INFRA_SSH_KNOWN_HOSTS }}" > $HOME/.ssh/known_hosts + - name: Install dependencies + run: ansible-galaxy install -r requirements.yml -f + - name: Run playbook + run: ansible-playbook -l Production_Hosts playbooks/everything.yaml