Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: modernize action and and lint-release-notes #27

Merged
merged 1 commit into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @open-turo/github-actions
6 changes: 0 additions & 6 deletions .github/dependabot.yaml

This file was deleted.

3 changes: 3 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["github>open-turo/renovate-config#v1"]
}
25 changes: 25 additions & 0 deletions .github/workflows/update-dependencies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Update dependencies
concurrency: update-dependencies

on:
schedule:
# Every day at midnight
- cron: "0 0 * * *"
workflow_dispatch:
issue_comment:
types:
- edited
pull_request:
types:
- edited

jobs:
update-dependencies:
runs-on: ubuntu-latest
name: Update dependencies
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: open-turo/action-renovate@v1
with:
github-token: ${{ secrets.OPEN_TURO_GITHUB_TOKEN }}
18 changes: 11 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0 # Use the ref you want to point at
rev: v4.5.0 # Use the ref you want to point at
hooks:
- id: check-json
- id: check-yaml
- id: pretty-format-json
args:
- --autofix
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.5.1
rev: v3.1.0
hooks:
- id: prettier
stages: [commit]
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v8.0.0
rev: v9.11.0
hooks:
- id: commitlint
stages: [commit-msg]
additional_dependencies: ["@open-turo/commitlint-config-conventional"]
- repo: https://github.com/rhysd/actionlint
rev: v1.6.8
rev: v1.6.26
hooks:
- id: actionlint
- repo: local
hooks:
- id: update-action-readme
name: update-action-readme
entry: ./script/update-action-readme
language: script
files: '.*/action\.yaml$'
14 changes: 1 addition & 13 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
{
"branches": [
"main",
{
"channel": "next",
"name": "(f|b|c)/*",
"prerelease": "beta-<%= (/^\\w+-\\d+/.exec(name.substr(2)) || [])[0] %>"
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github"
]
"extends": "@open-turo/semantic-release-config"
}
51 changes: 21 additions & 30 deletions lint/README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,33 @@
# GitHub Action Lint

<!-- prettier-ignore-start -->
<!-- action-docs-description -->
## Description

GitHub Action that lints a golang based repository via [action-pre-commit](https://github.com/open-turo/action-pre-commit)

## Usage

```yaml
jobs:
build:
steps:
- name: Lint
uses: open-turo/actions-go/lint@v1
with:
## example value for github-token provided below
github-token: ${{ secrets.GITHUB_TOKEN }}
```
GitHub Action that lints a Terraform based repository via [action-pre-commit](https://github.com/open-turo/action-pre-commit)
<!-- action-docs-description -->
<!-- prettier-ignore-end -->

<!-- prettier-ignore-start -->
<!-- action-docs-inputs -->
## Inputs

| parameter | description | required | default |
| ------------- | ----------------------------------------------------------------------------------- | -------- | ------- |
| checkout-repo | Perform checkout as first step of action | `false` | true |
| github-token | GitHub token that can checkout the consumer repository. e.g. 'secrets.GITHUB_TOKEN' | `true` | |

## Runs

This action is an `composite` action.
| parameter | description | required | default |
| --- | --- | --- | --- |
| checkout-repo | Perform checkout as first step of action | `false` | true |
| github-token | GitHub token that can checkout the consumer repository. e.g. 'secrets.GITHUB_TOKEN' | `true` | |
<!-- action-docs-inputs -->

## Lint Checks
<!-- action-docs-outputs -->

This action runs the following lint checks:
<!-- action-docs-outputs -->

- [action-pre-commit](https://github.com/open-turo/action-pre-commit)
<!-- action-docs-runs -->
## Runs

## Notes
This action is a `composite` action.
<!-- action-docs-runs -->

- By default, this action will perform actions/checkout as its first step.
- If the consumer repository has a `package-lock.json`:
- It will execute `npm ci` before running the `pre-commit` step.
- This expects that `.commitlintrc.yaml` will be present at the root level of the consumer repository to enforce [`conventional-commit`](https://github.com/wagoid/commitlint-github-action).
<!-- action-docs-usage -->
<!-- action-docs-usage -->
<!-- prettier-ignore-end -->
17 changes: 9 additions & 8 deletions lint/action.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "golang: Lint"
description: GitHub Action that lints a golang based repository via [action-pre-commit](https://github.com/open-turo/action-pre-commit)
name: terraform Lint
description: GitHub Action that lints a Terraform based repository via [action-pre-commit](https://github.com/open-turo/action-pre-commit)
inputs:
checkout-repo:
required: false
Expand All @@ -15,17 +15,18 @@ runs:
uses: actions/checkout@v4
if: inputs.checkout-repo == 'true'
with:
# Use fetch-depth of zero to obtain all commit history so that commit message linting can
# be properly performed.
fetch-depth: 0
- name: Setup tools
## Installs version of golang found in .go-version
uses: open-turo/action-setup-tools@v1
# Provide opportunity to install terraform, golang, and others
uses: open-turo/action-setup-tools@v2
- name: Authorize
uses: open-turo/action-git-auth@v2
with:
github-personal-access-token: ${{ inputs.github-token }}
- name: Run npm ci if needed
if: hashFiles('package-lock.json') != ''
shell: bash
run: npm ci
- name: Pre-commit
uses: open-turo/action-pre-commit@v1
- name: Check release notes on pull_request
if: github.event_name == 'pull_request'
uses: open-turo/actions-release/lint-release-notes@v4
77 changes: 23 additions & 54 deletions release/README.md
Original file line number Diff line number Diff line change
@@ -1,69 +1,38 @@
# GitHub Action Release

<!-- prettier-ignore-start -->
<!-- action-docs-description -->
## Description

GitHub Action that produces a new Release of a golang based repository.
<!-- action-docs-description -->
<!-- prettier-ignore-end -->

## Configuration

### Step1: Set any [Semantic Release Configuration](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#configuration) in the consumer repository.

### Step2: [Add Secrets](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets) in the consumer repository for the [Semantic Release Authentication](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/ci-configuration.md#authentication) Environment Variables.

### Step3: Add a [Workflow File](https://help.github.com/en/articles/workflow-syntax-for-github-actions) to the consumer repository to create custom automated processes.

## Usage

```yaml
steps:
- name: Release
uses: open-turo/actions-go/release@v1
with:
## example value for github-token provided below
github-token: ${{ secrets.GITHUB_TOKEN }}
```

**IMPORTANT**: `GITHUB_TOKEN` does not have the required permissions to operate on protected branches.
If you are using this action for protected branches, replace `GITHUB_TOKEN` with [Personal Access Token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line). If using the `@semantic-release/git` plugin for protected branches, avoid persisting credentials as part of `actions/checkout@v4` by setting the parameter `persist-credentials: false`. This credential does not have the required permission to operate on protected branches.

<!-- prettier-ignore-start -->
<!-- action-docs-inputs -->
## Inputs

| parameter | description | required | default |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------ | -------- | ------- |
| checkout-repo | Perform checkout as first step of action | `false` | true |
| github-token | GitHub token that can checkout the consumer repository as well as create tags/releases against it. e.g. 'secrets.GITHUB_TOKEN' | `true` | |
| go-version | Go version to use for building | `true` | 1.17.3 |
| parameter | description | required | default |
| --- | --- | --- | --- |
| checkout-repo | Perform checkout as first step of action | `false` | true |
| github-token | GitHub token that can checkout the consumer repository as well as create tags/releases against it. e.g. 'secrets.GITHUB_TOKEN' | `true` | |
| go-version | Go version to use for building | `true` | 1.17.3 |
<!-- action-docs-inputs -->

<!-- action-docs-outputs -->
## Outputs

| parameter | description |
| --------- | ---------------------- |
| version | Version of the project |
| parameter | description |
| --- | --- |
| version | Version of the project |
<!-- action-docs-outputs -->

<!-- action-docs-runs -->
## Runs

This action is an `composite` action.

## Additional Examples

### using output parameters example

```yaml
jobs:
build:
steps:
- name: Release
uses: open-turo/actions-go/release@v1
id: release # Need an `id` for output variables
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Do something when a new release published
if: steps.release.outputs.new-release-published == 'true'
run: |
echo ${{ steps.semantic.outputs.new-release-version }}
echo ${{ steps.semantic.outputs.new-release-major-version }}
```

## Notes
This action is a `composite` action.
<!-- action-docs-runs -->

- By default, this action will perform actions/checkout as its first step.
<!-- action-docs-usage -->
<!-- action-docs-usage -->
<!-- prettier-ignore-end -->
14 changes: 14 additions & 0 deletions script/update-action-readme
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -e

for i in $*; do
# ignore if the file does not end with /action.yaml
if [[ "$i" != *"/action.yaml" ]]; then
echo "skipping: ${i}"
continue
fi
readme_file=$(dirname "$i")/README.md
echo "npx action-docs --no-banner -a "${i}" --update-readme "${readme_file}""
npx action-docs --no-banner -a "${i}" --update-readme "${readme_file}"
done
46 changes: 20 additions & 26 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,33 @@
# GitHub Action Test

<!-- prettier-ignore-start -->
<!-- action-docs-description -->
## Description

GitHub Action that executes unit tests present anywhere within a golang based GitHub repository and reports results including coverage metrics
<!-- action-docs-description -->
<!-- prettier-ignore-end -->

## Usage

```yaml
jobs:
test:
steps:
- name: Test
uses: open-turo/actions-go/test@v1
with:
## example value for github-token provided below
github-token: ${{ secrets.GITHUB_TOKEN }}
```

<!-- prettier-ignore-start -->
<!-- action-docs-inputs -->
## Inputs

| parameter | description | required | default |
| ------------- | ----------------------------------------------------------------------------------- | -------- | ------- |
| checkout-repo | Perform checkout as first step of action | `false` | true |
| github-token | GitHub token that can checkout the consumer repository. e.g. 'secrets.GITHUB_TOKEN' | `true` | |
| parameter | description | required | default |
| --- | --- | --- | --- |
| checkout-repo | Perform checkout as first step of action | `false` | true |
| github-token | GitHub token that can checkout the consumer repository. e.g. 'secrets.GITHUB_TOKEN' | `true` | |
<!-- action-docs-inputs -->

## Runs
<!-- action-docs-outputs -->

This action is an `composite` action.
<!-- action-docs-outputs -->

## Test command used

```shell
go test -cover ./...
```
<!-- action-docs-runs -->
## Runs

## Notes
This action is a `composite` action.
<!-- action-docs-runs -->

- By default, this action will perform actions/checkout as its first step.
<!-- action-docs-usage -->
<!-- action-docs-usage -->
<!-- prettier-ignore-end -->
Loading