mirror of
https://github.com/ivuorinen/actions.git
synced 2026-02-10 02:45:49 +00:00
feat: add GitHub Actions workflows for code quality and automation (#2)
This commit is contained in:
35
go-version-detect/README.md
Normal file
35
go-version-detect/README.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# ivuorinen/actions/go-version-detect
|
||||
|
||||
## Go Version Detect
|
||||
|
||||
### Description
|
||||
|
||||
Detects the Go version from the project's go.mod file or defaults to a specified version.
|
||||
|
||||
### Inputs
|
||||
|
||||
| name | description | required | default |
|
||||
| ----------------- | -------------------------------------------------------- | -------- | ------- |
|
||||
| `default-version` | <p>Default Go version to use if go.mod is not found.</p> | `false` | `1.22` |
|
||||
|
||||
### Outputs
|
||||
|
||||
| name | description |
|
||||
| ------------ | -------------------------------------- |
|
||||
| `go-version` | <p>Detected or default Go version.</p> |
|
||||
|
||||
### Runs
|
||||
|
||||
This action is a `composite` action.
|
||||
|
||||
### Usage
|
||||
|
||||
```yaml
|
||||
- uses: ivuorinen/actions/go-version-detect@main
|
||||
with:
|
||||
default-version:
|
||||
# Default Go version to use if go.mod is not found.
|
||||
#
|
||||
# Required: false
|
||||
# Default: 1.22
|
||||
```
|
||||
36
go-version-detect/action.yml
Normal file
36
go-version-detect/action.yml
Normal file
@@ -0,0 +1,36 @@
|
||||
---
|
||||
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json
|
||||
name: Go Version Detect
|
||||
description: "Detects the Go version from the project's go.mod file or defaults to a specified version."
|
||||
author: 'Ismo Vuorinen'
|
||||
|
||||
branding:
|
||||
icon: code
|
||||
color: blue
|
||||
|
||||
inputs:
|
||||
default-version:
|
||||
description: 'Default Go version to use if go.mod is not found.'
|
||||
required: false
|
||||
default: '1.22'
|
||||
|
||||
outputs:
|
||||
go-version:
|
||||
description: 'Detected or default Go version.'
|
||||
value: ${{ steps.detect-go-version.outputs.go-version }}
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Detect Go Version
|
||||
id: detect-go-version
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -f go.mod ]; then
|
||||
version=$(grep '^go ' go.mod | awk '{print $2}')
|
||||
echo "Detected Go version: $version"
|
||||
echo "go-version=$version" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "No go.mod found. Using default Go version."
|
||||
echo "go-version=${{ inputs.default-version }}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
Reference in New Issue
Block a user