Sandbox Provisioning #619
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: Sandbox Provisioning | |
on: | |
pull_request: | |
paths: | |
- Vagrantfile | |
- provisioners/** | |
- vagrant.yaml | |
- lib/** | |
- .github/workflows/provision.yml | |
- requirements.d/ansible.txt | |
schedule: | |
- cron: "0 0 * * *" | |
jobs: | |
sandbox_provisioning: | |
runs-on: macos-12 | |
steps: | |
- name: "Checkout source code" | |
uses: "actions/checkout@v3.3.0" | |
- name: 'Cache Vagrant boxes' | |
uses: 'actions/cache@v3' | |
with: | |
path: '~/.vagrant.d/boxes' | |
key: ${{ runner.os }}-vagrant-${{ hashFiles('vagrant.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-vagrant- | |
- name: "Show Vagrant version" | |
run: | | |
vagrant --version | |
- name: 'Setup yq processor' | |
uses: 'chrisdickinson/setup-yq@v1.0.1' | |
with: | |
yq-version: 'v4.28.1' | |
- name: 'Update vagrant.yaml' | |
run: | | |
TAGS=$(yq ".[].roles[].tags" provisioners/ansible/playbook.yml) | |
TAGS="'${TAGS//[[:space:]]/"','"}'" | |
export TAGS="[${TAGS}]" | |
yq '.":host".":provisioners".":ansible".":options".":tags" = env(TAGS)' -i vagrant.yaml | |
yq '.":host".":cpus" = 3, .":host".":memory" = 3072' -i vagrant.yaml | |
- name: "Installation of Vagrant plugins" | |
run: | | |
vagrant up | |
- name: "Provision of the Vagrant (sandbox)" | |
run: | | |
vagrant up --provider=virtualbox | |
- name: "Destroy Vagrant (sandbox)" | |
run: | | |
vagrant destroy -f | |
if: '${{ success() || failure() }}' |