-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (70 loc) · 2.55 KB
/
pipeline.yaml
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
name: Push
on:
push:
branches:
- rule-sets-DTSPO-17918
permissions:
id-token: write
contents: read
actions: write
env:
TF_LOG: INFO
jobs:
deploy-infra:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
- name: 'Az CLI login'
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.DCD_CFT_SANDBOX_SUBSCRIPTION }}
- name: 'Run az commands'
run: |
az account show
- name: Install jq
run: |
sudo apt-get install jq -y
- name: Debug Repositories and Branches
run: |
echo "Checking Repositories and Branches"
cat ./test-repos.json
for repo in $(jq -r '.[]' ./test-repos.json); do
echo "Checking repository: $repo"
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/hmcts/$repo
for branch in main master; do
echo "Checking branch: $branch in repository: $repo"
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/hmcts/$repo/branches/$branch
done
done
- name: Terraform Init and Plan
id: plan
working-directory: ./components
env:
STORAGE_ACCOUNT: ${{ secrets.STORAGE_ACCOUNT }}
CONTAINER_NAME: ${{ secrets.CONTAINER_NAME }}
RESOURCE_GROUP_NAME: ${{ secrets.RESOURCE_GROUP_NAME }}
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.DCD_CFT_SANDBOX_SUBSCRIPTION }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
terraform init -backend-config="storage_account_name=$STORAGE_ACCOUNT" -backend-config="container_name=$CONTAINER_NAME" -backend-config="resource_group_name=$RESOURCE_GROUP_NAME"
terraform plan -out=tfplan
- name: Terraform apply
working-directory: ./components
id: apply
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.DCD_CFT_SANDBOX_SUBSCRIPTION }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: terraform apply -auto-approve tfplan