From ddb45d991add94912c7b515005e4b7423a699728 Mon Sep 17 00:00:00 2001 From: Toshiya-Kato Date: Mon, 3 Jun 2024 19:44:21 +0900 Subject: [PATCH] fix to specify terraform version --- .github/workflows/depup.yml | 37 ------------------------------------- Dockerfile | 5 ----- action.yml | 1 + entrypoint.sh | 6 ++++++ 4 files changed, 7 insertions(+), 42 deletions(-) diff --git a/.github/workflows/depup.yml b/.github/workflows/depup.yml index 1f64d33..7d9883e 100644 --- a/.github/workflows/depup.yml +++ b/.github/workflows/depup.yml @@ -35,40 +35,3 @@ jobs: branch: depup/reviewdog base: main labels: "bump:minor" - terraform: - runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - steps: - - uses: actions/checkout@v4 - - uses: reviewdog/action-depup@v1 - id: depup - with: - file: Dockerfile - version_name: TERRAFORM_VERSION - repo: hashicorp/terraform - - name: Check if the latest version matches x.y.z - id: check_version - run: | - if [[ "${{ steps.depup.outputs.latest }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "match=true" >> "$GITHUB_OUTPUT" - else - echo "match=false" >> "$GITHUB_OUTPUT" - fi - - - name: Create Pull Request - if: steps.check_version.outputs.match == 'true' - uses: peter-evans/create-pull-request@v6 - with: - token: ${{ secrets.GITHUB_TOKEN }} - title: "chore(deps): update terraform to ${{ steps.depup.outputs.latest }}" - commit-message: "chore(deps): update terraform to ${{ steps.depup.outputs.latest }}" - body: | - Update terraform to [v${{ steps.depup.outputs.latest }}](https://github.com/hashicorp/terraform/releases/tag/v${{ steps.depup.outputs.latest }}) - Compare [v${{ steps.depup.outputs.current }}...v${{ steps.depup.outputs.latest }}](https://github.com/hashicorp/terraform/compare/v${{ steps.depup.outputs.current }}...v${{ steps.depup.outputs.latest }}) - - This PR is auto generated by [depup workflow](https://github.com/${{ github.repository }}/actions?query=workflow%3Adepup). - branch: depup/terraform - base: main - labels: "bump:minor" diff --git a/Dockerfile b/Dockerfile index 8bf18e9..38331ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ FROM alpine:3.20 -ARG TERRAFORM_VERSION=1.7.3 ARG REVIEWDOG_VERSION=v0.17.4 SHELL ["/bin/ash", "-eo", "pipefail", "-c"] @@ -9,10 +8,6 @@ RUN apk --no-cache add git jq RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION} -RUN wget -q https://releases.hashicorp.com/terraform/"${TERRAFORM_VERSION}"/terraform_"${TERRAFORM_VERSION}"_linux_amd64.zip \ - && unzip ./terraform_"${TERRAFORM_VERSION}"_linux_amd64.zip -d /usr/local/bin/ \ - && rm -rf ./terraform_"${TERRAFORM_VERSION}"_linux_amd64.zip - COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] diff --git a/action.yml b/action.yml index 2ae7acf..27406f8 100644 --- a/action.yml +++ b/action.yml @@ -31,6 +31,7 @@ inputs: ### Variables for terraform validate ### terraform_version: description: 'The terraform version to install and use.' + default: '1.7.3' runs: using: 'docker' image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh index f9cb670..7bd55bf 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,11 +1,17 @@ #!/bin/sh set -e +TERRAFORM_VERSION=$1 + if [ -n "${GITHUB_WORKSPACE}" ] ; then cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit 1 git config --global --add safe.directory "${GITHUB_WORKSPACE}" || exit 1 fi +wget -q https://releases.hashicorp.com/terraform/"${TERRAFORM_VERSION}"/terraform_"${TERRAFORM_VERSION}"_linux_amd64.zip \ + && unzip ./terraform_"${TERRAFORM_VERSION}"_linux_amd64.zip -d /usr/local/bin/ \ + && rm -rf ./terraform_"${TERRAFORM_VERSION}"_linux_amd64.zip + export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" jq_script='