From b2637b8a7efc342a1e99eb665cba4ed7dace2a2f Mon Sep 17 00:00:00 2001 From: Victor Date: Sat, 3 Feb 2024 03:25:45 +0000 Subject: [PATCH] feat: modernize action and and lint-release-notes --- .github/CODEOWNERS | 1 + .github/dependabot.yaml | 6 -- .github/renovate.json | 3 + .github/workflows/update-dependencies.yaml | 25 +++++++ .pre-commit-config.yaml | 18 +++-- .releaserc.json | 14 +--- lint/README.md | 51 ++++++-------- lint/action.yaml | 17 ++--- release/README.md | 77 +++++++--------------- script/update-action-readme | 14 ++++ test/README.md | 46 ++++++------- 11 files changed, 128 insertions(+), 144 deletions(-) create mode 100644 .github/CODEOWNERS delete mode 100644 .github/dependabot.yaml create mode 100644 .github/renovate.json create mode 100644 .github/workflows/update-dependencies.yaml create mode 100755 script/update-action-readme diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..bfd546e --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @open-turo/github-actions diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml deleted file mode 100644 index 253bcb7..0000000 --- a/.github/dependabot.yaml +++ /dev/null @@ -1,6 +0,0 @@ -version: 2 -updates: - - package-ecosystem: github-actions - directory: / - schedule: - interval: daily diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 0000000..32417a5 --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,3 @@ +{ + "extends": ["github>open-turo/renovate-config#v1"] +} diff --git a/.github/workflows/update-dependencies.yaml b/.github/workflows/update-dependencies.yaml new file mode 100644 index 0000000..85d1ca8 --- /dev/null +++ b/.github/workflows/update-dependencies.yaml @@ -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 }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2e7b01d..5efbdb2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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$' diff --git a/.releaserc.json b/.releaserc.json index df364cb..db57aea 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -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" } diff --git a/lint/README.md b/lint/README.md index 3472f89..dd7e16d 100644 --- a/lint/README.md +++ b/lint/README.md @@ -1,42 +1,33 @@ # GitHub Action Lint + + ## 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) + + + + ## 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` | | + -## Lint Checks + -This action runs the following lint checks: + -- [action-pre-commit](https://github.com/open-turo/action-pre-commit) + +## Runs -## Notes +This action is a `composite` action. + -- 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). + + + diff --git a/lint/action.yaml b/lint/action.yaml index c467844..52ee3b1 100644 --- a/lint/action.yaml +++ b/lint/action.yaml @@ -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 @@ -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 diff --git a/release/README.md b/release/README.md index ac735c6..829a19d 100644 --- a/release/README.md +++ b/release/README.md @@ -1,69 +1,38 @@ # GitHub Action Release + + ## Description GitHub Action that produces a new Release of a golang based repository. + + -## 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. - + + ## 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 | + + ## Outputs -| parameter | description | -| --------- | ---------------------- | -| version | Version of the project | +| parameter | description | +| --- | --- | +| version | Version of the project | + + ## 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. + -- By default, this action will perform actions/checkout as its first step. + + + diff --git a/script/update-action-readme b/script/update-action-readme new file mode 100755 index 0000000..00247ce --- /dev/null +++ b/script/update-action-readme @@ -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 diff --git a/test/README.md b/test/README.md index 6036043..b8acbee 100644 --- a/test/README.md +++ b/test/README.md @@ -1,39 +1,33 @@ # GitHub Action Test + + ## Description GitHub Action that executes unit tests present anywhere within a golang based GitHub repository and reports results including coverage metrics + + -## 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 }} -``` - + + ## 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` | | + -## Runs + -This action is an `composite` action. + -## Test command used - -```shell -go test -cover ./... -``` + +## Runs -## Notes +This action is a `composite` action. + -- By default, this action will perform actions/checkout as its first step. + + +