diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6d3bc9c..c20ef98 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,6 +34,8 @@ jobs: if: github.event_name == 'pull_request' name: runner / terraform validate (github-pr-review) runs-on: ubuntu-latest + permissions: + pull-requests: write steps: - uses: actions/checkout@v4 - uses: ./ @@ -43,6 +45,3 @@ jobs: level: error reviewdog_flags: -filter-mode=file -fail-on-error workdir: ./testdata/ - envvar: | - KEY1=value1 - KEY2=value2 diff --git a/.gitignore b/.gitignore index 34a39ac..08b09b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ # Folders to ignore -.vscode/ \ No newline at end of file +.vscode/ +.DS_Store +.terraform diff --git a/README.md b/README.md index bebd343..5ee2f98 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ [![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/maruLoop/action-terraform-validate?logo=github&sort=semver)](https://github.com/maruLoop/action-terraform-validate/releases) [![action-bumpr supported](https://img.shields.io/badge/bumpr-supported-ff69b4?logo=github&link=https://github.com/haya14busa/action-bumpr)](https://github.com/haya14busa/action-bumpr) -![github-pr-review demo](https://user-images.githubusercontent.com/3797062/73162963-4b8e2b00-4132-11ea-9a3f-f9c6f624c79f.png) -![github-pr-check demo](https://user-images.githubusercontent.com/3797062/73163032-70829e00-4132-11ea-8481-f213a37db354.png) +![github-pr-review demo](images/pr-comment.png) +![github-pr-check demo](images/pr-check.png) This action runs [terraform validate](https://developer.hashicorp.com/terraform/cli/commands/validate) with [reviewdog](https://github.com/reviewdog/reviewdog) on pull requests to improve experience. @@ -43,10 +43,6 @@ inputs: description: 'Additional reviewdog flags' default: '' ### Variables for Terraform ### - terraform_init_options: - description: 'options for terraform init to pass backend configuration and so on' - envvars: - description: 'Environment variables for terraform init to pass backend configuration' terraform_version: description: 'The terraform version to install and use. The default is `latest`' ``` @@ -70,6 +66,4 @@ jobs: # Change reporter level if you need. # GitHub Status Check won't become failure with warning. level: warning - envvars: | - AWS_REGION=ap-northeast-1 ``` diff --git a/action.yml b/action.yml index 1618698..b4ecf85 100644 --- a/action.yml +++ b/action.yml @@ -29,10 +29,6 @@ inputs: description: 'Additional reviewdog flags' default: '' ### Variables for terraform validate ### - terraform_init_options: - description: 'options for terraform init to pass backend configuration and so on' - envvars: - description: 'Environment variables for terraform init to pass backend configuration' terraform_version: description: 'The terraform version to install and use. The default is `latest`' runs: diff --git a/entrypoint.sh b/entrypoint.sh index 6d56538..4494fd3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,12 +7,9 @@ if [ -n "${GITHUB_WORKSPACE}" ] ; then fi export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" -echo "${INPUT_ENVVARS}" | while IFS= read -r line; do - export line -done +terraform init -backend=false # shellcheck disable=SC2086 -terraform init ${INPUT_TERRAFORM_INIT_OPTIONS} terraform validate -json \ | jq -r '.diagnostics[] | "\(.range.filename):\(.range.start.line):\(.range.start.column): \(.detail)"' \ | reviewdog -efm="%f:%l:%c:%m" \ diff --git a/images/pr-check.png b/images/pr-check.png new file mode 100644 index 0000000..dfb7226 Binary files /dev/null and b/images/pr-check.png differ diff --git a/images/pr-comment.png b/images/pr-comment.png new file mode 100644 index 0000000..3539727 Binary files /dev/null and b/images/pr-comment.png differ