Skip to content

Commit

Permalink
Merge pull request #8 from andrewslotin/support_custom_imports
Browse files Browse the repository at this point in the history
Support custom imports
  • Loading branch information
andrewslotin authored Feb 6, 2023
2 parents bfc19ec + 53ba622 commit 50fea06
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ The action accepts `gopath` parameter to specify the URL of a self-hosted or any
goproxy: https://gocenter.io
```

### Custom import path

In case your module uses custom import path, such as `example.com/myproject`, an attempt to download it using its GitHub reporitory URL will result in an error. In this case you need to provide the import path of your package as an input:

```yaml
- name: Pull new module version
uses: andrewslotin/go-proxy-pull-action@v1.1.0
with:
import_path: example.com/myproject
```

Why?
----

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ inputs:
description: 'URL of the proxy to be passed to `go get` as GOPROXY='
required: false
default: 'https://proxy.golang.org'
import_path:
description: 'Package import path. If not set, github.com/<user>/<repo> is used as a default'
required: false
default: ''
runs:
using: 'docker'
image: 'Dockerfile'
Expand Down
8 changes: 6 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
readonly TAG=${GITHUB_REF#refs/tags/*}
readonly VERSION=${TAG##*/}

PACKAGE=github.com/${GITHUB_REPOSITORY}
PACKAGE=${INPUT_IMPORT_PATH:=github.com/${GITHUB_REPOSITORY}}

# submodules version tags are formatted as <submodule>/vX.Y.Z,
# so we extract the submodule name and append it to the main module
# import path
if [[ "$VERSION" != "$TAG" ]]; then
PACKAGE=github.com/${GITHUB_REPOSITORY}/${TAG%"/$VERSION"}
PACKAGE=${PACKAGE}/${TAG%"/$VERSION"}
fi

# if version > 1, then add the version scope
Expand Down

0 comments on commit 50fea06

Please sign in to comment.