From 87b19204c0e895876ea2d7975da93b054e977d82 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Sat, 15 Aug 2020 08:42:50 +0000 Subject: [PATCH] Migrate from docker to composite run actions https://docs.github.com/en/actions/creating-actions/creating-a-composite-run-steps-action It should be able to reuse the go build cache and share the same build context/environment by using the same default workspace instead of using Docker. It should resolve an issue such as #21 as well. --- .github/workflows/dockerimage.yml | 14 -------------- Dockerfile | 11 ----------- action.yml | 18 ++++++++++++++++-- entrypoint.sh | 11 +++++++++++ 4 files changed, 27 insertions(+), 27 deletions(-) delete mode 100644 .github/workflows/dockerimage.yml delete mode 100644 Dockerfile diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml deleted file mode 100644 index a924ec71..00000000 --- a/.github/workflows/dockerimage.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Docker Image CI - -on: [push] - -jobs: - - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag reviewdog-golangci-lint:$(date +%s) diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 9a36602b..00000000 --- a/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM golangci/golangci-lint:v1.30-alpine - -ENV REVIEWDOG_VERSION=v0.10.2 - -RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${REVIEWDOG_VERSION} - -RUN apk --no-cache add git - -COPY entrypoint.sh /entrypoint.sh - -ENTRYPOINT ["/entrypoint.sh"] diff --git a/action.yml b/action.yml index 7b4dd091..183b79a1 100644 --- a/action.yml +++ b/action.yml @@ -35,8 +35,22 @@ inputs: description: 'Working directory relative to the root directory.' default: '.' runs: - using: 'docker' - image: 'Dockerfile' + using: 'composite' + steps: + - run: $GITHUB_ACTION_PATH/entrypoint.sh + shell: bash + env: + REVIEWDOG_VERSION: v0.10.2 + GOLANGCI_LINT_VERSION: v1.30.0 + INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} + INPUT_GOLANGCI_LINT_FLAGS: ${{ inputs.golangci_lint_flags }} + INPUT_TOOL_NAME: ${{ inputs.tool_name }} + INPUT_LEVEL: ${{ inputs.level }} + INPUT_REPORTER: ${{ inputs.reporter }} + INPUT_FILTER_MODE: ${{ inputs.filter_mode }} + INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }} + INPUT_REVIEWDOG_FLAGS: ${{ inputs.reviewdog_flags }} + INPUT_WORKDIR: ${{ inputs.workdir }} branding: icon: 'check-circle' color: 'blue' diff --git a/entrypoint.sh b/entrypoint.sh index 4ab27324..e496e98c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,6 +2,17 @@ cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit 1 +TEMP_PATH="$(mktemp -d)" +PATH="${TEMP_PATH}:$PATH" + +echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog' +curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" "${REVIEWDOG_VERSION}" 2>&1 +echo '::endgroup::' + +echo '::group::🐶 Installing golangci-lint ... https://github.com/golangci/golangci-lint' +curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "${TEMP_PATH}" "${GOLANGCI_LINT_VERSION}" 2>&1 +echo '::endgroup::' + export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" # shellcheck disable=SC2086