Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/shoothzj/go-mod-check-action


https://github.com/shoothzj/go-mod-check-action

Last synced: 10 days ago
JSON representation

Awesome Lists containing this project

README

        

# go-mod-check-action

This GitHub Action checks if your `go.mod` and `go.sum` files are properly updated and optionally prevents indirect
dependency updates.

## Requirements

- Go 1.17+

## Features

1. Runs `go mod tidy` to check if `go.mod` and `go.sum` files have any changes. If there are changes, the action fails.
2. If `prohibitIndirectDepUpdate` is set to `true`, the action will first remove indirect dependency blocks (excluding
replace blocks) from `go.mod`, then run `go mod tidy`, and check if the `go.mod` and `go.sum` files have any changes
compared to the initial state. If there are changes, the action fails.

## Usage

To use this action in your project, follow these steps:

1. Add a new workflow file or edit an existing one in your project's `.github/workflows` directory. For example, create
or edit `.github/workflows/go-mod-check.yml`.
2. Add the following content to the file:

```yaml
name: Go Mod Check

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
go-mod-check:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Run Go Mod Check Action
uses: Shoothzj/go-mod-check-action@main
with:
prohibitIndirectDepUpdate: 'true'
```

Now, the `go-mod-check-action` will run on every push/pr to your project, ensuring that the `go.mod` and `go.sum` files
are properly updated and preventing indirect dependency updates if required.

## Configuration

You can configure the action using the following input parameters:

| **Parameter** | **Description** | **Required** | **Default** |
|-----------------------------|-------------------------------------------------------------------------|--------------|-------------|
| `prohibitIndirectDepUpdate` | If set to `true`, the action will prohibit indirect dependency updates. | No | `false` |

## License

This project is licensed under the [Apache 2.0 License](LICENSE).