terraform plan and apply from github actions #5
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 Playbook Weekly Update Servers | |
on: | |
push: | |
branches: ["main"] | |
paths: | |
- "ansible/**" | |
- ".github/workflows/**" | |
schedule: | |
- cron: "0 0 * * 6" | |
env: | |
ANSIBLE_HOSTS_FILE: ${{ secrets.ANSIBLE_HOSTS_FILE }} | |
ANSIBLE_SSH_PRIVATE_KEY_FILE: ${{ secrets.ANSIBLE_SSH_PRIVATE_KEY_FILE }} | |
jobs: | |
update-servers: | |
name: Update Servers | |
runs-on: self-hosted | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set Environment Variables | |
working-directory: ansible | |
run: | | |
mkdir inventory | |
echo $ANSIBLE_HOSTS_FILE | base64 -d > inventory/hosts | |
echo $ANSIBLE_SSH_PRIVATE_KEY_FILE | base64 -d > ansible_key | |
chmod 600 ansible_key | |
- name: Run Ansible Playbook | |
working-directory: ansible | |
run: | | |
ansible-playbook update.yaml |