forked from port-labs/tf-provision-landing-zone
-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (59 loc) · 2.15 KB
/
Copy pathapply-tf-and-report.yml
File metadata and controls
62 lines (59 loc) · 2.15 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
name: Apply terraform configuration
concurrency:
group: "terraform-provisioner"
cancel-in-progress: false
on:
push:
branches:
- "main"
paths:
- "terraform/**/*.tf"
jobs:
pull-and-apply:
defaults:
run:
working-directory: terraform
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
PORT_CLIENT_ID: ${{ secrets.PORT_CLIENT_ID }}
PORT_CLIENT_SECRET: ${{ secrets.PORT_CLIENT_SECRET }}
AWS_REGION: "eu-west-1"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: true
- uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
- name: Terraform Init
id: init
run: terraform init
- name: Terraform Validate
id: validate
run: terraform validate -no-color
- name: Terraform Apply
id: apply
run: terraform apply -auto-approve -var port_client_id=${{ env.PORT_CLIENT_ID }} -var port_client_secret=${{ env.PORT_CLIENT_SECRET }} -no-color
- name: Extract relevant output
id: plan-output
run: |
echo "RUN_ID=$(echo ${{ github.event.head_commit.message }} | awk '{ print $1}')" >> $GITHUB_ENV
- name: GetToken
uses: fjogeleit/http-request-action@v1
id: get-token
with:
url: "https://api.getport.io/v1/auth/access_token"
method: "POST"
customHeaders: '{"Content-Type": "application/json"}'
data: '{"clientId": "${{ secrets.PORT_CLIENT_ID }}", "clientSecret": "${{ secrets.PORT_CLIENT_SECRET }}"}'
- name: FinishAction
uses: fjogeleit/http-request-action@v1
with:
url: "https://api.getport.io/v1/actions/runs/${{ env.RUN_ID }}"
method: "PATCH"
bearerToken: ${{ fromJson(steps.get-token.outputs.response).accessToken }}
customHeaders: '{"Content-Type": "application/json"}'
data: '{"status": "SUCCESS", "link": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"}'
# TODO: Need to fix the workflow