-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (75 loc) · 3.21 KB
/
support-deployment.yml
File metadata and controls
89 lines (75 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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-22.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