-
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.
- Loading branch information
Showing
1 changed file
with
28 additions
and
26 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 |
|---|---|---|
| @@ -1,40 +1,42 @@ | ||
| name: Terraform CI/CD | ||
| name: Terraform Validate | ||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| types: [closed] | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| terraform-ci-cd: | ||
| runs-on: 229685449397 | ||
|
|
||
| terraform-validate: | ||
| runs-on: "229685449397" | ||
| permissions: | ||
| contents: write | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: CSVD/gh-actions-checkout@v4 | ||
|
|
||
| - name: Setup GITHUB Credentials | ||
| id: github_credentials | ||
| uses: CSVD/gh-auth@main | ||
| - name: Setup Terraform | ||
| uses: CSVD/gh-actions-setup-terraform@v2 | ||
| with: | ||
| github_app_pem_file: ${{ secrets.GH_APP_PEM_FILE }} | ||
| github_app_installation_id: ${{ vars.GH_APP_INSTALLATION_ID }} | ||
| github_app_id: ${{ vars.GH_APP_ID }} | ||
| terraform_version: '1.10.5' | ||
|
|
||
| - name: Validate Terraform Configuration | ||
| id: validate | ||
| uses: CSVD/terraform-validate@main | ||
|
|
||
| - name: Setup GitHub CLI | ||
| - name: Check Validation/Test Results | ||
| if: always() | ||
| run: | | ||
| # Force manual authentication since setup-git might not work with GitHub Enterprise | ||
| echo "${{ steps.github_credentials.outputs.github_token }}" > /tmp/token.txt | ||
| gh auth login --with-token --hostname "github.e.it.census.gov" < /tmp/token.txt | ||
| rm /tmp/token.txt | ||
| # Set default values if outputs are empty | ||
| IS_VALID="${{ steps.validate.outputs.is_valid }}" | ||
| TESTS_PASSED="${{ steps.validate.outputs.tests_passed }}" | ||
| # Test GitHub CLI auth status | ||
| gh auth status || echo "GitHub CLI authentication failed" | ||
| # If outputs are empty, set them to false | ||
| [ -z "$IS_VALID" ] && IS_VALID="false" | ||
| [ -z "$TESTS_PASSED" ] && TESTS_PASSED="false" | ||
| - name: Run Release Action | ||
| uses: CSVD/releaser@main | ||
| with: | ||
| github-token: ${{ steps.github_credentials.outputs.github_token }} | ||
| working-directory: '.' | ||
| if [[ "$IS_VALID" != "true" || "$TESTS_PASSED" != "true" ]]; then | ||
| echo "Validation or test errors found:" | ||
| echo "${{ steps.validate.outputs.stderr }}" | ||
| exit 1 | ||
| else | ||
| echo "All validations and tests passed successfully!" | ||
| fi |