Skip to content

Commit f87ba0c

Browse files
committed
Refresh before sync
1 parent 91c0d55 commit f87ba0c

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

.github/workflows/sync.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
description: Whether to acquire terraform state lock during sync
1313
required: false
1414
default: "true"
15+
refresh:
16+
description: Refresh terraform state before sync
17+
required: false
18+
default: "false"
1519

1620
jobs:
1721
prepare:
@@ -77,6 +81,11 @@ jobs:
7781
terraform workspace select "${TF_WORKSPACE_OPT}" || terraform workspace new "${TF_WORKSPACE_OPT}"
7882
echo "TF_WORKSPACE=${TF_WORKSPACE_OPT}" >> $GITHUB_ENV
7983
working-directory: terraform
84+
- name: Refresh terraform state
85+
if: ${{ github.event.inputs.refresh == 'true' }}
86+
run:
87+
echo "{}" > $TF_WORKSPACE.tfstate.json
88+
terraform apply -refresh-only -auto-approve -lock=$TF_LOCK
8089
- name: Pull terraform state
8190
run: |
8291
terraform show -json > $TF_WORKSPACE.tfstate.json

0 commit comments

Comments
 (0)