diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 86ad2ea..544fd1f 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -12,6 +12,10 @@ on: description: Whether to acquire terraform state lock during sync required: false default: "true" + refresh: + description: Refresh terraform state before sync + required: false + default: "false" jobs: prepare: @@ -77,10 +81,14 @@ jobs: terraform workspace select "${TF_WORKSPACE_OPT}" || terraform workspace new "${TF_WORKSPACE_OPT}" echo "TF_WORKSPACE=${TF_WORKSPACE_OPT}" >> $GITHUB_ENV working-directory: terraform - - name: Pull terraform state + - name: Refresh terraform state + if: ${{ github.event.inputs.refresh == 'true' }} run: | echo "{}" > $TF_WORKSPACE.tfstate.json - terraform refresh + terraform apply -refresh-only -auto-approve -lock=$TF_LOCK + working-directory: terraform + - name: Pull terraform state + run: | terraform show -json > $TF_WORKSPACE.tfstate.json working-directory: terraform - name: Install pnpm