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