我是新的使用Github动作和编码到YAML文件。
目前,我为我的Datadog POC设置了Terraform Github操作。
我来到这个问题上:
terraform init
/home/runner/work/_temp/85297372-6fed-4b1d-88f8-3c6b5527569f/terraform-bin init
Terraform initialized in an empty directory!
The directory has no Terraform configuration files. You may begin working
with Terraform immediately by creating Terraform configuration files.
当前的github操作yaml文件是:
I use the terraform github actions yaml file
name: 'Terraform'
on:
push:
branches:
- "main"
pull_request:
permissions:
contents: read
jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
environment: production
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
defaults:
run:
shell: bash
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v3
# Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: Terraform Init
run: terraform init
# Checks that all Terraform configuration files adhere to a canonical format
- name: Terraform Format
run: terraform fmt -check
# Generates an execution plan for Terraform
- name: Terraform Plan
run: terraform plan -input=false
# On push to "main", build or change infrastructure according to Terraform configuration files
# Note: It is recommended to set up a required "strict" status check in your repository for "Terraform Cloud". See the documentation on "strict" required status checks for more information: https://help.github.com/en/github/administering-a-repository/types-of-required-status-checks
- name: Terraform Apply
if: github.ref == 'refs/heads/"main"' && github.event_name == 'push'
run: terraform apply -auto-approve -input=false
在这里我该做什么补救措施?
我试图将terraform init中包含的目录更改为
运行:working目录:./DataDog/terraform,但我也收到了错误。
谢谢
发布于 2022-07-21 12:01:09
您必须将cd放入包含所有terraform文件的目录中。就像这样
- name: Build Docker image
run: |
cd dir或者,您也可以像这样设置工作目录
steps:
- uses: actions/checkout@v1
- name: Setup and run tests
working-directory: ./app
run: |
cp .env .env或
jobs:
unit:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./app
steps:
- uses: actions/checkout@v1
- name: Do stuffhttps://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsrun
https://stackoverflow.com/questions/73065738
复制相似问题