Deploy and Release #5
Workflow file for this run
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 and Release | |
on: | |
push: | |
tags: | |
- 'v*.*.*' # Triggers workflow on version tags like v1.0.0 | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repository | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
# Set up Terraform | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v1 | |
with: | |
terraform_version: 1.4.6 | |
# Generate SSH Key | |
- name: Generate SSH Key | |
run: | | |
mkdir -p $GITHUB_WORKSPACE/iac-dev-container-data | |
ssh-keygen -t ecdsa -b 521 -N '' -f $GITHUB_WORKSPACE/iac-dev-container-data/id_ecdsa | |
# Clean Terraform Cache | |
- name: Clean Terraform Cache | |
run: rm -rf .terraform .terraform.lock.hcl | |
# Terraform Init | |
- name: Terraform Init | |
run: terraform init | |
# Fix Provider Plugin Permissions | |
- name: Fix Provider Plugin Permissions | |
run: chmod +x .terraform/providers/registry.terraform.io/opennebula/opennebula/*/linux_amd64/terraform-provider-opennebula_* | |
# Terraform Apply | |
- name: Terraform Apply | |
run: terraform apply -auto-approve | |
# Generate Ansible Inventory | |
- name: Generate Ansible Inventory | |
run: python3 generate_inventory.py | |
# Set up Ansible | |
- name: Install Ansible | |
run: sudo apt update && sudo apt install -y ansible | |
# Run Ansible Playbook | |
- name: Run Ansible Playbook | |
run: ansible-playbook -i ansible/inventory.yml ansible/playbook.yml | |
release: | |
runs-on: ubuntu-latest | |
needs: build-and-deploy # Ensures this runs after the deploy job | |
steps: | |
# Checkout the repository | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
# Create a Release | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
README.md | |
terraform.tf | |
ansible/inventory.yml | |
ansible/playbook.yml | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |