-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
temporary build provider from main for demo
- Loading branch information
Showing
3 changed files
with
27 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,52 +2,41 @@ name: 'aiven_terraform_governance_compliance_check' | |
description: 'GitHub Action to check whether the plan generated by terraform plan complies with governance rules on aiven terraform provider resources.' | ||
author: 'Aiven' | ||
|
||
outputs: | ||
result: | ||
description: "the compliance result" | ||
value: ${{ steps.check-governance-compliance.outputs.result }} | ||
|
||
inputs: | ||
GITHUB_TOKEN: | ||
description: 'A GitHub access token that has permission to read the target pull request.' | ||
requester: | ||
description: 'The github username that created the pull request' | ||
required: true | ||
|
||
approvers: | ||
description: 'The github usernames (csv) that have approved the pull request' | ||
required: true | ||
|
||
AIVEN_API_TOKEN: | ||
description: 'A Aiven API access token used for terraform plan' | ||
plan: | ||
description: 'Plan generated by terraform plan -json' | ||
required: true | ||
|
||
|
||
outputs: | ||
result: | ||
description: "the compliance result" | ||
value: ${{ steps.check.outputs.result }} | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: "Get approvers" | ||
id: approvers | ||
uses: octokit/[email protected] | ||
with: | ||
route: GET /repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews | ||
env: | ||
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} | ||
|
||
- name: "Checkout branch" | ||
id: checkout-branch | ||
uses: actions/checkout@v4 | ||
|
||
- name: "Setup terraform" | ||
id: setup-terraform | ||
uses: hashicorp/setup-terraform@v3 | ||
- name: Setup go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: ${{ github.action_path }}/go.mod | ||
|
||
- name: "Check compliance" | ||
id: check-compliance | ||
env: | ||
PROVIDER_AIVEN_ENABLE_BETA: 1 | ||
run: | | ||
terraform init | ||
terraform plan -out=plan -var="aiven_api_token=${{ inputs.AIVEN_API_TOKEN }}" | ||
terraform show -json plan > ./plan.json | ||
REQUESTER=${{ github.event.pull_request.user.login }} | ||
APPROVERS=$(echo '${{ steps.approvers.outputs.data }}' | jq '[.[] | select(.state == "APPROVED") | .user.login] | unique') | ||
RESULT=$(./build/checker -plan=plan.json -requester=$REQUESTER -approvers=$APPROVERS) | ||
- name: Check Aiven Terraform Governance Compliance | ||
id: check | ||
run: | ||
RESULT=$( | ||
${{ github.action_path }}/build/checker -plan=${{ inputs.plan }} -requester=${{ inputs.requester }} -approvers=${{ inputs.approvers }} | ||
) | ||
echo $RESULT | ||
echo "result=$RESULT" >> "$GITHUB_OUTPUT" | ||
shell: bash | ||
shell: bash | ||
|
||
branding: | ||
icon: 'shield' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters