Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurav-nelson authored May 13, 2024
0 parents commit ed50240
Show file tree
Hide file tree
Showing 15 changed files with 481 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[*.sh]
indent_size = 2
indent_style = space
17 changes: 17 additions & 0 deletions .github/labels.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"name": "bump:major",
"color": "ef6bb4",
"description": "Attach to PR to automatically bump major version on merge"
},
{
"name": "bump:minor",
"color": "ef6bb4",
"description": "Attach to PR to automatically bump minor version on merge"
},
{
"name": "bump:patch",
"color": "ef6bb4",
"description": "Attach to PR to automatically bump patch version on merge"
}
]
8 changes: 8 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": [
"config:base"
],
"labels": [
"bump:patch"
]
}
19 changes: 19 additions & 0 deletions .github/workflows/depup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: depup
on:
schedule:
- cron: "14 14 * * *" # Runs at 14:14 UTC every day
repository_dispatch:
types: [depup]
workflow_dispatch:

jobs:
reviewdog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: reviewdog/action-depup/with-pr@v1
with:
file: action.yml
version_name: reviewdog_version
repo: reviewdog/reviewdog
labels: "bump:minor"
20 changes: 20 additions & 0 deletions .github/workflows/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: labels
on:
push:
paths:
- .github/labels.json
- .github/workflows/labels.yml
branches:
- main
workflow_dispatch:
jobs:
label:
name: Manage GitHub labels
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Manage labels
uses: lannonbr/issue-label-manager-action@4.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: release
on:
push:
branches:
- main
tags:
- "v*.*.*"
pull_request:
types:
- labeled

jobs:
release:
if: github.event.action != 'labeled'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# Bump version on merging Pull Requests with specific labels.
# (bump:major,bump:minor,bump:patch)
- id: bumpr
if: "!startsWith(github.ref, 'refs/tags/')"
uses: haya14busa/action-bumpr@v1

# Update corresponding major and minor tag.
# e.g. Update v1 and v1.2 when releasing v1.2.3
- uses: haya14busa/action-update-semver@v1
if: "!steps.bumpr.outputs.skip"
with:
tag: ${{ steps.bumpr.outputs.next_version }}

# Get tag name.
- id: tag
uses: haya14busa/action-cond@v1
with:
cond: "${{ startsWith(github.ref, 'refs/tags/') }}"
if_true: ${{ github.ref }}
if_false: ${{ steps.bumpr.outputs.next_version }}

# Create release
- if: "steps.tag.outputs.value != ''"
env:
TAG_NAME: ${{ steps.tag.outputs.value }}
BODY: ${{ steps.bumpr.outputs.message }}
# This token is provided by Actions, you do not need to create your own token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${TAG_NAME}" -t "Release ${TAG_NAME}" --notes "${BODY}"
release-check:
if: github.event.action == 'labeled'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Post bumpr status comment
uses: haya14busa/action-bumpr@v1
60 changes: 60 additions & 0 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: reviewdog
on:
push:
branches:
- main
pull_request:
jobs:
shellcheck:
name: runner / shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: haya14busa/action-cond@v1
id: reporter
with:
cond: ${{ github.event_name == 'pull_request' }}
if_true: "github-pr-review"
if_false: "github-check"
- uses: reviewdog/action-shellcheck@v1
with:
reporter: ${{ steps.reporter.outputs.value }}
level: warning

shfmt:
name: runner / shfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: reviewdog/action-shfmt@v1

actionlint:
name: runner / actionlint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: reviewdog/action-actionlint@v1
with:
reporter: github-check
level: warning

misspell:
name: runner / misspell
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: reviewdog/action-misspell@v1
with:
reporter: github-check
level: warning
locale: "US"

alex:
name: runner / alex
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: reviewdog/action-alex@v1
with:
reporter: github-check
level: warning
52 changes: 52 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Test
on:
push:
branches:
- main
pull_request:
# TODO: replace `<linter-name>` with yours
jobs:
test-check:
name: runner / <linter-name> (github-check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./
with:
github_token: ${{ secrets.github_token }}
reporter: github-check
level: info
locale: "US"

test-pr-check:
if: github.event_name == 'pull_request'
name: runner / <linter-name> (github-pr-check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
level: warning
locale: "US"
workdir: ./testdata/subdir/

test-pr-review:
if: github.event_name == 'pull_request'
name: runner / <linter-name> (github-pr-review)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./
continue-on-error: true
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
level: error
locale: "US"
filter_mode: file
fail_on_error: true
- name: check the exit code
if: ${{ !success() }}
run: echo 'The previous step should fail' && exit 1
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Folders to ignore
.vscode/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 reviewdog developers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
124 changes: 124 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# action-composite-template

<!-- TODO: replace reviewdog/action-composite-template with your repo name -->
[![Test](https://github.com/reviewdog/action-composite-template/workflows/Test/badge.svg)](https://github.com/reviewdog/action-composite-template/actions?query=workflow%3ATest)
[![reviewdog](https://github.com/reviewdog/action-composite-template/workflows/reviewdog/badge.svg)](https://github.com/reviewdog/action-composite-template/actions?query=workflow%3Areviewdog)
[![depup](https://github.com/reviewdog/action-composite-template/workflows/depup/badge.svg)](https://github.com/reviewdog/action-composite-template/actions?query=workflow%3Adepup)
[![release](https://github.com/reviewdog/action-composite-template/workflows/release/badge.svg)](https://github.com/reviewdog/action-composite-template/actions?query=workflow%3Arelease)
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/reviewdog/action-composite-template?logo=github&sort=semver)](https://github.com/reviewdog/action-composite-template/releases)
[![action-bumpr supported](https://img.shields.io/badge/bumpr-supported-ff69b4?logo=github&link=https://github.com/haya14busa/action-bumpr)](https://github.com/haya14busa/action-bumpr)

![github-pr-review demo](https://user-images.githubusercontent.com/3797062/73162963-4b8e2b00-4132-11ea-9a3f-f9c6f624c79f.png)
![github-pr-check demo](https://user-images.githubusercontent.com/3797062/73163032-70829e00-4132-11ea-8481-f213a37db354.png)

<!-- TODO: outline your action here -->
This is a template repository for
[reviewdog](https://github.com/reviewdog/reviewdog) action with release
automation based on [action composition](https://docs.github.com/en/actions/creating-actions/creating-a-composite-action).
Click `Use this template` button to create your reviewdog action :dog:!

If you want to create your own reviewdog action from scratch without using this
template, please check and copy release automation flow.
It's important to manage release workflow and sync reviewdog version for all
reviewdog actions.

This repo contains a sample action to run [misspell](https://github.com/client9/misspell).

## Input

<!-- TODO: replace `<linter-name>` with yours -->
```yaml
inputs:
github_token:
description: 'GITHUB_TOKEN'
default: '${{ github.token }}'
workdir:
description: 'Working directory relative to the root directory.'
default: '.'
### Flags for reviewdog ###
tool_name:
description: 'Tool name to use for reviewdog reporter.'
default: '<linter-name>'
level:
description: 'Report level for reviewdog [info,warning,error].'
default: 'error'
reporter:
description: 'Reporter of reviewdog command [github-check,github-pr-review,github-pr-check].'
default: 'github-check'
filter_mode:
description: |
Filtering mode for the reviewdog command [added,diff_context,file,nofilter].
Default is added.
default: 'added'
fail_on_error:
description: |
Exit code for reviewdog when errors are found [true,false].
Default is `false`.
default: 'false'
reviewdog_flags:
description: 'Additional reviewdog flags.'
default: ''
### Flags for <linter-name> ###
locale:
description: '-locale flag of misspell. (US/UK)'
default: ''
```
## Usage
<!-- TODO: replace reviewdog/action-composite-template with your repo name -->
```yaml
name: reviewdog
on: [pull_request]
jobs:
# TODO: replace `linter_name` and `<linter-name>` with yours
linter_name:
name: runner / <linter-name>
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: reviewdog/action-composite-template@v1
with:
github_token: ${{ secrets.github_token }}
# Change reviewdog reporter if you need [github-check,github-pr-review,github-pr-check].
reporter: github-pr-review
# Change reporter level if you need.
# GitHub Status Check won't become failure with warning.
level: warning
```
## Development
### Release
#### [haya14busa/action-bumpr](https://github.com/haya14busa/action-bumpr)
You can bump version on merging Pull Requests with specific labels (bump:major,bump:minor,bump:patch).
Pushing tag manually by yourself also work.
#### [haya14busa/action-update-semver](https://github.com/haya14busa/action-update-semver)
This action updates major/minor release tags on a tag push. e.g. Update v1 and v1.2 tag when released v1.2.3.
ref: https://help.github.com/en/articles/about-actions#versioning-your-action
### Lint - reviewdog integration
This reviewdog action itself is integrated with reviewdog to run lints
which is useful for [action composition] based actions.
[action composition]:https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
![reviewdog integration](https://user-images.githubusercontent.com/3797062/72735107-7fbb9600-3bde-11ea-8087-12af76e7ee6f.png)
Supported linters:
- [reviewdog/action-shellcheck](https://github.com/reviewdog/action-shellcheck)
- [reviewdog/action-shfmt](https://github.com/reviewdog/action-shfmt)
- [reviewdog/action-actionlint](https://github.com/reviewdog/action-actionlint)
- [reviewdog/action-misspell](https://github.com/reviewdog/action-misspell)
- [reviewdog/action-alex](https://github.com/reviewdog/action-alex)
### Dependencies Update Automation
This repository uses [reviewdog/action-depup](https://github.com/reviewdog/action-depup) to update
reviewdog version.
![reviewdog depup demo](https://user-images.githubusercontent.com/3797062/73154254-170e7500-411a-11ea-8211-912e9de7c936.png)
Loading

0 comments on commit ed50240

Please sign in to comment.