fix(ci): replace actions/checkout with git clone
Some checks failed
Terraform CI/CD / Validate (push) Failing after 1s
Terraform CI/CD / Plan (push) Has been skipped
Terraform CI/CD / Apply (push) Has been skipped

- Remove actions/checkout@v4 (requires Node.js not in Alpine image)
- Use native git clone instead
- Remove actions/upload-artifact and download-artifact (require Node.js)
- Re-run plan in apply job instead of artifact transfer
- Add workflow file to paths trigger for testing

Refs #3
This commit is contained in:
2025-12-08 09:00:24 +00:00
parent 6036783cd5
commit ba4b530635

View File

@@ -6,11 +6,13 @@ on:
- dev - dev
paths: paths:
- 'terraform/**' - 'terraform/**'
- '.gitea/workflows/terraform.yml'
pull_request: pull_request:
branches: branches:
- dev - dev
paths: paths:
- 'terraform/**' - 'terraform/**'
- '.gitea/workflows/terraform.yml'
env: env:
TF_WORKING_DIR: terraform/prod TF_WORKING_DIR: terraform/prod
@@ -33,7 +35,9 @@ jobs:
image: gitea.arnodo.fr/damien/terraform-ci:latest image: gitea.arnodo.fr/damien/terraform-ci:latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 run: |
git clone --depth 1 --branch ${{ gitea.ref_name }} ${{ gitea.server_url }}/${{ gitea.repository }}.git .
git checkout ${{ gitea.sha }}
- name: Terraform Format Check - name: Terraform Format Check
id: fmt id: fmt
@@ -86,7 +90,9 @@ jobs:
plan_exitcode: ${{ steps.plan.outputs.exitcode }} plan_exitcode: ${{ steps.plan.outputs.exitcode }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 run: |
git clone --depth 1 --branch ${{ gitea.ref_name }} ${{ gitea.server_url }}/${{ gitea.repository }}.git .
git checkout ${{ gitea.sha }}
- name: Terraform Init - name: Terraform Init
run: terraform init -input=false run: terraform init -input=false
@@ -106,14 +112,13 @@ jobs:
exit 0 exit 0
working-directory: ${{ env.TF_WORKING_DIR }} working-directory: ${{ env.TF_WORKING_DIR }}
- name: Upload Plan - name: Save Plan Output
uses: actions/upload-artifact@v4 if: always()
with: run: |
name: tfplan mkdir -p /tmp/tfplan-artifact
path: | cp tfplan /tmp/tfplan-artifact/ 2>/dev/null || true
${{ env.TF_WORKING_DIR }}/tfplan cp plan_output.txt /tmp/tfplan-artifact/ 2>/dev/null || true
${{ env.TF_WORKING_DIR }}/plan_output.txt working-directory: ${{ env.TF_WORKING_DIR }}
retention-days: 7
- name: Plan Summary - name: Plan Summary
if: always() if: always()
@@ -176,20 +181,18 @@ jobs:
needs.plan.outputs.plan_exitcode == '2' needs.plan.outputs.plan_exitcode == '2'
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 run: |
git clone --depth 1 --branch ${{ gitea.ref_name }} ${{ gitea.server_url }}/${{ gitea.repository }}.git .
- name: Download Plan git checkout ${{ gitea.sha }}
uses: actions/download-artifact@v4
with:
name: tfplan
path: ${{ env.TF_WORKING_DIR }}
- name: Terraform Init - name: Terraform Init
run: terraform init -input=false run: terraform init -input=false
working-directory: ${{ env.TF_WORKING_DIR }} working-directory: ${{ env.TF_WORKING_DIR }}
- name: Terraform Apply - name: Terraform Plan and Apply
run: terraform apply -input=false -auto-approve tfplan run: |
terraform plan -input=false -out=tfplan
terraform apply -input=false -auto-approve tfplan
working-directory: ${{ env.TF_WORKING_DIR }} working-directory: ${{ env.TF_WORKING_DIR }}
- name: Apply Summary - name: Apply Summary