Skip to content

Commit

Permalink
Get rid of Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
vavsab committed Aug 27, 2024
1 parent a3c80ac commit ee09c2c
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 140 deletions.
1 change: 0 additions & 1 deletion .github/FUNDING.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/dependabot.yml

This file was deleted.

70 changes: 41 additions & 29 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,48 @@
name: Build
on:
release:
types: [published]
on:
push:

jobs:
permissions:
contents: write

jobs:
build:
name: Build image
name: Build
runs-on: ubuntu-latest
steps:

- name: Login to Registry
run: |
echo ${{ secrets.DOCKER_PASSWORD }} | \
docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Build image
run: |
export VERSION=${GITHUB_REF#refs/tags/}
export VERSION_MINOR=$(echo ${VERSION} | awk '{match($0,"v[0-9].[0-9]",a)}END{print a[0]}')
export VERSION_MAJOR=$(echo ${VERSION} | awk '{match($0,"v[0-9]",a)}END{print a[0]}')
docker build --build-arg ACTION_VERSION=${VERSION} \
-t morphy/revive-action \
-t morphy/revive-action:${VERSION} \
-t morphy/revive-action:${VERSION_MINOR} \
-t morphy/revive-action:${VERSION_MAJOR} .
- name: Publish image
run: docker push --all-tags morphy/revive-action

- name: Logout
run: docker logout
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Build
run: go build -v ./...

- name: Release branch name
id: release_branch_name
run: |
branch=latest
if [[ $GITHUB_REF != refs/heads/main ]]; then
branch=dev-${GITHUB_REF#refs/heads/}
fi
echo "branch=$branch"
echo "branch=$branch" >> $GITHUB_OUTPUT
- name: Copy release files
run: |
mkdir -p release
cp go.mod go.sum main.go action.yaml entrypoint.sh release/
- name: Publish into release branch
uses: s0/git-publish-subdir-action@v2.6.0
env:
REPO: self
BRANCH: ${{ steps.release_branch_name.outputs.branch }}
FOLDER: release
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 changes: 0 additions & 31 deletions .github/workflows/lint.yaml

This file was deleted.

32 changes: 0 additions & 32 deletions Dockerfile

This file was deleted.

22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
# Revive Action

👉Same as [morphy2k/revive-action](https://github.com/marketplace/actions/revive-action) but not using Docker.

Problems when using Docker:
1. Takes time pull the image.
1. Cannot upgrade Go quickly.

This Action runs [Revive](https://github.com/mgechev/revive) on your [Go](https://golang.org/) code and adds annotations to the check.

## Usage

Checkout
Prepare your workflow by adding the following steps:

```YAML
- name: Check out code into the Go module directory
uses: actions/checkout@v2
```

Use by pulling pre-built image **(recommended)**
```YAML
- name: Run Revive Action by pulling pre-built image
uses: docker://morphy/revive-action:v2
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
```
Use by building from repository
Run
```YAML
- name: Run Revive Action by building from repository
uses: morphy2k/revive-action@v2
uses: mapped/revive-action@master
```
Configuration
Expand Down
29 changes: 16 additions & 13 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ name: "Revive Action"
description: "Lint your Go code with Revive"
author: "Markus Wiegand"
branding:
icon: "code"
color: "blue"
icon: "code"
color: "blue"
inputs:
config:
description: "Path of the Revive config file"
required: false
exclude:
description: "Revive exclude patterns, separated by semicolons"
required: false
path:
description: "Revive path pattern"
required: false
config:
description: "Path of the Revive config file"
required: false
exclude:
description: "Revive exclude patterns, separated by semicolons"
required: false
path:
description: "Revive path pattern"
required: false
runs:
using: "docker"
image: "Dockerfile"
using: "composite"
steps:
- run: ${{ github.action_path }}/entrypoint.sh
shell: bash

30 changes: 25 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,31 @@
set -e
set -o pipefail

REVIVE_VERSION="v1.3.9"

echo "Downloading revive $REVIVE_VERSION binary..."

# Download and untar revive action from GitHub

ARCH=$(uname -m)
if [ "$ARCH" = "aarch64" ]; then
REVIVE_ARCH="arm64"
else
REVIVE_ARCH="amd64"
fi

mkdir -p revive
cd revive

curl -sSL -o revive.tar.gz https://github.com/mgechev/revive/releases/download/$REVIVE_VERSION/revive_linux_$REVIVE_ARCH.tar.gz
tar -xvzf revive.tar.gz

REVIVE="$GITHUB_ACTION_PATH/revive/revive"
echo "Downloaded revive binary to $REVIVE_ACTION"

cd "$GITHUB_WORKSPACE"

ACTION_VERSION=$(revive-action -version)
REVIVE_VERSION=$(revive -version | gawk '{match($0,"v[0-9].[0-9].[0-9]",a)}END{print a[0]}')
REVIVE_ACTION="go run $GITHUB_ACTION_PATH/main.go"

LINT_PATH="./..."

Expand All @@ -19,7 +40,6 @@ done

if [ ! -z "${INPUT_CONFIG}" ]; then CONFIG="-config=$INPUT_CONFIG"; fi

echo "ACTION: $ACTION_VERSION
REVIVE: $REVIVE_VERSION"
echo "Running revive..."

eval "revive $CONFIG $EXCLUDES -formatter ndjson $LINT_PATH | revive-action"
eval "$REVIVE_ACTION $CONFIG $EXCLUDES -formatter ndjson $LINT_PATH | $REVIVE_ACTION"

0 comments on commit ee09c2c

Please sign in to comment.