Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cedrickring/golang-action
A GitHub Action to run Go commands
https://github.com/cedrickring/golang-action
action ci github-actions golang golang-action
Last synced: about 1 month ago
JSON representation
A GitHub Action to run Go commands
- Host: GitHub
- URL: https://github.com/cedrickring/golang-action
- Owner: cedrickring
- License: apache-2.0
- Archived: true
- Created: 2019-01-04T20:57:40.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-09-10T07:54:28.000Z (about 3 years ago)
- Last Synced: 2024-09-26T09:21:59.929Z (about 1 month ago)
- Topics: action, ci, github-actions, golang, golang-action
- Language: Shell
- Homepage:
- Size: 1.1 MB
- Stars: 133
- Watchers: 2
- Forks: 33
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome-actions - GitHub Actions for Golang
- fucking-awesome-actions - GitHub Actions for Golang
- awesome-workflows - GitHub Actions for Golang
README
[![](https://img.shields.io/github/release/cedrickring/golang-action.svg)](https://github.com/cedrickring/golang-action/releases/latest) [![Actions Status](https://github.com/cedrickring/golang-action/workflows/Build%20on%20Push/badge.svg)](https://github.com/cedrickring/golang-action/actions)
**IMPORTANT**: This action will **no longer be maintained** by myself and thus will not support versions newer than Golang 1.16. I highly recommend using the [offical actions/setup-go action](https://github.com/actions/setup-go) which does exactly the same as this action (+ with some more features). Originally this action was helpful when there was the requirement to properly place go projects in the `$GOPATH`. As this is no longer needed, setting up the proper go version is all you need. However I will kindly review and approve PRs with bugfixes only.
# Golang Action
This Action allows you to run Go commands with your code. It will automatically setup your workspace (`~/go/src/github.com//`) before the command is run.
## How to use
Create a `workflow.yaml` file in `.github/workflows` with the following contents:
```yaml
on: push
name: My cool Action
jobs:
checks:
name: run
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master- name: run
uses: cedrickring/[email protected]
```If no args are specified and a `Makefile` is detected, this action will run `make`. Otherwise `go test` and `go build` will be run.
To run a custom command, just use:
```yaml
steps:
- name: Run custom command
uses: cedrickring/[email protected]
with:
args: make my-target
```If your repository's `import` name is different from the path on GitHub,
provide the `import` name by adding an environment variable
`IMPORT=import/name`. This may be useful if you have forked an open
source Go project:
```yaml
steps:
- name: Run with custom import path
uses: cedrickring/[email protected]
env:
IMPORT: "root/repo"
```To use Go Modules add `GO111MODULE=on` to the step:
```yaml
steps:
- name: Go Modules
uses: cedrickring/[email protected]
env:
GO111MODULE: "on"
```If your go project is not located at the root of the repo you can also specify environment variable `PROJECT_PATH`:
```yaml
steps:
- name: Custom project path
uses: cedrickring/[email protected]
env:
PROJECT_PATH: "./path/in/my/project"
```To use a specific golang version (1.10, 1.11, 1.12, 1.13, 1.14, 1.15), defaults to the latest version:
```yaml
steps:
- name: Use Go 1.11
uses: cedrickring/golang-action/[email protected]
```