-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (92 loc) · 3.03 KB
/
pull-request.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: "pull request"
on:
pull_request:
branches: [main]
paths-ignore:
- "README.md"
- "catalog.yaml"
env:
IMAGE_PATH: ${{ github.repository_owner }}/gratibot
permissions:
id-token: write
pull-requests: write
contents: read
packages: write
jobs:
setup:
name: Pipeline Setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate tag
id: tag
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
outputs:
docker-tag: ${{ steps.tag.outputs.sha_short }}
build:
name: Docker
needs: setup
uses: liatrio/github-workflows/.github/workflows/docker-build.yaml@main
with:
repository: ghcr.io/liatrio
image-name: gratibot
tag: ${{ needs.setup.outputs.docker-tag }}
fmt:
name: "Terraform fmt check"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Terraform fmt check
run: terraform fmt -check -recursive
validate:
name: "Terraform validate check"
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Terragrunt
run: |
wget https://github.com/gruntwork-io/terragrunt/releases/download/v0.45.11/terragrunt_linux_amd64
sudo mv terragrunt_linux_amd64 /usr/local/bin/terragrunt
sudo chmod +x /usr/local/bin/terragrunt
- name: Terraform validate check
run: |
terragrunt init -backend=false
terragrunt validate --terragrunt-no-auto-init
working-directory: infra/terragrunt/nonprod/gratibot/
env:
TF_VAR_gratibot_image: "${{ env.IMAGE_PATH }}:${{ needs.build.outputs.docker_tag }}"
plan:
name: "Terraform Nonprod plan"
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Terragrunt
run: |
wget https://github.com/gruntwork-io/terragrunt/releases/download/v0.45.11/terragrunt_linux_amd64
sudo mv terragrunt_linux_amd64 /usr/local/bin/terragrunt
sudo chmod +x /usr/local/bin/terragrunt
- name: Plan Gratibot staging deployment
id: plan_gratibot_staging_deployment
working-directory: infra/terragrunt/nonprod/gratibot/
run: |
terragrunt plan -out plan.out
terragrunt show -no-color -json plan.out > plan.json
continue-on-error: true
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_TENANT_ID: "1b4a4fed-fed8-4823-a8a0-3d5cea83d122"
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_NONPROD_SUBSCRIPTION_ID }}
ARM_USE_OIDC: true
TF_VAR_gratibot_image: "${{ env.IMAGE_PATH }}:${{ needs.build.outputs.docker_tag }}"
- uses: liatrio/terraform-change-pr-commenter@v1.5.0
with:
json-file: infra/terragrunt/nonprod/gratibot/plan.json
expand-comment: 'true'
- name: Status
if: contains(steps.*.outcome, 'failure')
run: exit 1