Support Deployment #90
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: 'Support Deployment' | |
# Only trigger, when the deployment workflow succeeded | |
on: | |
workflow_run: | |
workflows: ["Deployment"] | |
branches: [main] | |
types: | |
- completed | |
jobs: | |
terraform: | |
name: 'Terraform' | |
runs-on: ubuntu-20.04 | |
steps: | |
# Configure AWS credentials | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v3 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: eu-west-1 | |
mask-aws-account-id: true | |
# Checkout plugin-infrastructure repository to the GitHub Actions runner | |
- uses: actions/checkout@v4 | |
with: | |
repository: AltaPay/plugin-infrastructure | |
token: ${{ secrets.ACCESS_TOKEN }} | |
ref: 'main' | |
# Install version 1.0.8 of Terraform CLI | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v2 | |
with: | |
terraform_version: 1.0.8 | |
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc. | |
- name: Terraform Init | |
run: terraform init | |
working-directory: provision/plugins | |
# Select a Terraform workspace | |
- name: Terraform workspace | |
run: terraform workspace select wordpress-support | |
working-directory: provision/plugins | |
# Generates an execution plan for Terraform | |
- name: Terraform Plan | |
run: terraform plan | |
working-directory: provision/plugins | |
# Run Terraform Apply | |
# On push to main, build or change infrastructure according to Terraform configuration files | |
# Note: It is recommended to set up a required "strict" status check in your repository for "Terraform Cloud". See the documentation on "strict" required status checks for more information: https://help.github.com/en/github/administering-a-repository/types-of-required-status-checks | |
- name: Terraform Apply | |
#if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
run: terraform apply -var ec2_type=t3a.micro -auto-approve | |
working-directory: provision/plugins | |
# Add a sleep of 20 seconds, in case instance needs to warm up | |
- name: Sleep for 20 seconds | |
uses: jakejarvis/wait-action@master | |
with: | |
time: '20s' | |
#Run Ansible playbook | |
- name: Run playbook | |
uses: dawidd6/action-ansible-playbook@v2 | |
with: | |
playbook: wordpress.yml | |
directory: deploy/plugins | |
key: ${{secrets.SSHKEY}} | |
options: | | |
-u ubuntu | |
-i inventory | |
--extra-vars "variable_host=wordpress-support branch_name=main gatewayURL=${{ secrets.GATEWAYURL }} gatewayUser=${{ secrets.GATEWAYUSER }} gatewayPass=${{ secrets.GATEWAYPASS }} wp_user=${{secrets.CMS_ADMIN_USER}} wp_pass=${{secrets.CMS_ADMIN_PASS_SUPPORT}} wp_email=${{secrets.CMS_ADMIN_EMAIL}}" | |
# Export URL | |
- name: Export URL | |
run: | | |
testvar=$(sed '4!d' inventory) | |
echo $testvar | |
echo "IP=$testvar">> $GITHUB_ENV | |
echo "http://$IP/wordpress" | |
working-directory: deploy/plugins |