Some checks failed
Terraform Plan / Terraform Plan (push) Failing after 9s
Configure an s3 backend and initialize Terraform in CI with backend config from Gitea secrets so state persists across runs and apply operations stay consistent.
69 lines
2.1 KiB
YAML
69 lines
2.1 KiB
YAML
name: Terraform Plan
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- stage
|
|
- test
|
|
|
|
jobs:
|
|
terraform:
|
|
name: "Terraform Plan"
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Create secrets.tfvars
|
|
working-directory: terraform
|
|
run: |
|
|
echo "PM_API_TOKEN_SECRET length: $(echo -n '${{ secrets.PM_API_TOKEN_SECRET }}' | wc -c)"
|
|
cat > secrets.auto.tfvars << EOF
|
|
pm_api_token_secret = "${{ secrets.PM_API_TOKEN_SECRET }}"
|
|
EOF
|
|
cat > backend.hcl << EOF
|
|
bucket = "${{ secrets.B2_TF_BUCKET }}"
|
|
key = "terraform.tfstate"
|
|
region = "us-east-005"
|
|
endpoint = "${{ secrets.B2_TF_ENDPOINT }}"
|
|
access_key = "${{ secrets.B2_KEY_ID }}"
|
|
secret_key = "${{ secrets.B2_APPLICATION_KEY }}"
|
|
skip_credentials_validation = true
|
|
skip_metadata_api_check = true
|
|
skip_region_validation = true
|
|
skip_requesting_account_id = true
|
|
force_path_style = true
|
|
EOF
|
|
echo "Created secrets.auto.tfvars:"
|
|
cat secrets.auto.tfvars | sed 's/=.*/=***/'
|
|
echo "Using token ID from terraform.tfvars:"
|
|
grep '^pm_api_token_id' terraform.tfvars
|
|
|
|
- name: Set up Terraform
|
|
uses: hashicorp/setup-terraform@v2
|
|
with:
|
|
terraform_version: 1.6.6
|
|
|
|
- name: Terraform Init
|
|
working-directory: terraform
|
|
run: terraform init -reconfigure -backend-config=backend.hcl
|
|
|
|
- name: Terraform Format Check
|
|
working-directory: terraform
|
|
run: terraform fmt -check -recursive
|
|
|
|
- name: Terraform Validate
|
|
working-directory: terraform
|
|
run: terraform validate
|
|
|
|
- name: Terraform Plan
|
|
working-directory: terraform
|
|
run: terraform plan -out=tfplan
|
|
|
|
- name: Upload Terraform Plan
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: terraform-plan
|
|
path: terraform/tfplan
|