-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (54 loc) · 1.75 KB
/
terraform.yml
File metadata and controls
63 lines (54 loc) · 1.75 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
name: 'Apply the configuration and delete this repo'
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
# push:
# branches:
# - 'main'
# TODO Fix token not working
jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.SETUP_TOKEN }}
TFE_TOKEN: ${{ secrets.TF_CLOUD_PERSONAL_API_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
cli_config_credentials_token: ${{ secrets.TF_CLOUD_PERSONAL_API_TOKEN }}
- name: Terraform Format
id: fmt
run: terraform fmt -check
- name: Terraform Init
id: init
run: terraform init
- name: Terraform Validate
id: validate
run: terraform validate -no-color
- name: Terraform Apply
if: github.ref == 'refs/heads/main'
run: |
echo "tfe_owners_team_id = \"${{ vars.TFE_OWNERS_TEAM_ID }}\"" > terraform.auto.tfvars
echo "github_token = \"${{ secrets.SETUP_TOKEN }}\"" >> terraform.auto.tfvars
echo "tfe_token = \"${{ secrets.TF_CLOUD_PERSONAL_API_TOKEN }}\"" >> terraform.auto.tfvars
terraform apply -auto-approve -input=false
#delete-repo:
# runs-on: ubuntu-latest
# needs:
# - terraform
# steps:
# - name: Delete this repository
# env:
# GITHUB_TOKEN: ${{ secrets.SETUP_TOKEN }}
# run: |
# echo "Deleting the current repository..."
# curl -X DELETE \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: token $GITHUB_TOKEN" \
# "https://api.github.com/repos/${{ github.repository }}"