Use caching instead of artifacts to store .terraform (#2)
Co-authored-by: Ben Martin <ben.martin@sky.uk> Reviewed-on: #2
This commit is contained in:
parent
6b2f1c473f
commit
ba5f3704d4
2 changed files with 15 additions and 10 deletions
|
@ -15,6 +15,7 @@ env:
|
||||||
TF_IN_AUTOMATION: true
|
TF_IN_AUTOMATION: true
|
||||||
TF_CLI_ARGS: "-no-color"
|
TF_CLI_ARGS: "-no-color"
|
||||||
PG_CONN_STR: "${{ secrets.PG_CONN_STR }}"
|
PG_CONN_STR: "${{ secrets.PG_CONN_STR }}"
|
||||||
|
TF_PLUGIN_CACHE_DIR: ${{ gitea.workspace }}/.terraform.d/plugin-cache
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
plan:
|
plan:
|
||||||
|
@ -22,9 +23,15 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: hashicorp/setup-terraform@v3
|
- uses: hashicorp/setup-terraform@v3
|
||||||
|
- name: Create Terraform Plugin Cache Dir
|
||||||
|
run: mkdir -v -p $TF_PLUGIN_CACHE_DIR
|
||||||
|
- uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ${{ env.TF_PLUGIN_CACHE_DIR }}
|
||||||
|
key: ${{ runner.os }}-terraform-${{ hashFiles('**/.terraform.lock.hcl') }}
|
||||||
- name: Terraform fmt
|
- name: Terraform fmt
|
||||||
id: fmt
|
id: fmt
|
||||||
run: terraform fmt -check
|
run: terraform fmt -recursive -check
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
- name: Terraform Init
|
- name: Terraform Init
|
||||||
id: init
|
id: init
|
||||||
|
@ -92,10 +99,6 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: tfplan
|
name: tfplan
|
||||||
path: tfplan
|
path: tfplan
|
||||||
- uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: .terraform
|
|
||||||
path: .terraform
|
|
||||||
apply:
|
apply:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: plan
|
needs: plan
|
||||||
|
@ -103,13 +106,15 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: hashicorp/setup-terraform@v3
|
- uses: hashicorp/setup-terraform@v3
|
||||||
|
- name: Create Terraform Plugin Cache Dir
|
||||||
|
run: mkdir -v -p $TF_PLUGIN_CACHE_DIR
|
||||||
|
- uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ${{ env.TF_PLUGIN_CACHE_DIR }}
|
||||||
|
key: ${{ runner.os }}-terraform-${{ hashFiles('**/.terraform.lock.hcl') }}
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: tfplan
|
name: tfplan
|
||||||
- uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: .terraform
|
|
||||||
path: .terraform
|
|
||||||
- name: Ensure providers are executable
|
- name: Ensure providers are executable
|
||||||
run: chmod -Rv +x .terraform/providers
|
run: chmod -Rv +x .terraform/providers
|
||||||
- name: Terraform apply
|
- name: Terraform apply
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
resource "nomad_job" "dummy" {
|
resource "nomad_job" "dummy" {
|
||||||
jobspec = file("${path.module}/jobspec.json")
|
jobspec = file("${path.module}/jobspec.json")
|
||||||
json = true
|
json = true
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue