Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
HollowMan6 committed Apr 17, 2023
0 parents commit a56a83c
Show file tree
Hide file tree
Showing 14 changed files with 442 additions and 0 deletions.
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"
]
}
34 changes: 34 additions & 0 deletions .github/workflows/depup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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@v3
- uses: reviewdog/action-depup@v1
id: depup
with:
file: Dockerfile
version_name: REVIEWDOG_VERSION
repo: reviewdog/reviewdog

- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}"
commit-message: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}"
body: |
Update reviewdog to [v${{ steps.depup.outputs.latest }}](https://github.com/reviewdog/reviewdog/releases/tag/v${{ steps.depup.outputs.latest }})
Compare [v${{ steps.depup.outputs.current }}...v${{ steps.depup.outputs.latest }}](https://github.com/reviewdog/reviewdog/compare/v${{ steps.depup.outputs.current }}...v${{ steps.depup.outputs.latest }})
This PR is auto generated by [depup workflow](https://github.com/${{ github.repository }}/actions?query=workflow%3Adepup).
branch: depup/reviewdog
base: master
labels: "bump:minor"
13 changes: 13 additions & 0 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Docker Image CI
on:
push:
branches:
- master
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --file Dockerfile --tag ${{ github.repository }}:$(date +%s)
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:
- master
tags:
- "v*.*.*"
pull_request:
types:
- labeled

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

# 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/refs\/tags\//}" --notes "${BODY}"
release-check:
if: github.event.action == 'labeled'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Post bumpr status comment
uses: haya14busa/action-bumpr@v1
63 changes: 63 additions & 0 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: reviewdog
on:
push:
branches:
- master
pull_request:
jobs:
shellcheck:
name: runner / shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- 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:
github_token: ${{ secrets.github_token }}
reporter: ${{ steps.reporter.outputs.value }}
level: warning

hadolint:
name: runner / hadolint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- 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-hadolint@v1
with:
github_token: ${{ secrets.github_token }}
reporter: ${{ steps.reporter.outputs.value }}
level: warning

misspell:
name: runner / misspell
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: reviewdog/action-misspell@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-check
level: warning
locale: "US"

alex:
name: runner / alex
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: reviewdog/action-alex@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-check
level: warning
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test
on:
push:
branches:
- master
pull_request:
jobs:
test-check:
name: runner / <linter-name> (github-check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- 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@v3
- 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@v3
- uses: ./
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
level: error
locale: "US"
reviewdog_flags: -filter-mode=file -fail-on-error
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/
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM alpine:3.17

ENV REVIEWDOG_VERSION=v0.14.1

SHELL ["/bin/ash", "-eo", "pipefail", "-c"]

# hadolint ignore=DL3006
RUN apk --no-cache add git

Check warning on line 8 in Dockerfile

View workflow job for this annotation

GitHub Actions / runner / hadolint

[hadolint] reported by reviewdog 🐶 Pin versions in apk add. Instead of `apk add <package>` use `apk add <package>=<version>` Raw Output: message:"Pin versions in apk add. Instead of `apk add <package>` use `apk add <package>=<version>`" location:{path:"Dockerfile" range:{start:{line:8 column:1}}} severity:WARNING source:{name:"hadolint" url:"https://github.com/hadolint/hadolint"} code:{value:"DL3018" url:"https://github.com/hadolint/hadolint/wiki/DL3018"}

Check warning on line 8 in Dockerfile

View workflow job for this annotation

GitHub Actions / runner / hadolint

[hadolint] reported by reviewdog 🐶 Pin versions in apk add. Instead of `apk add <package>` use `apk add <package>=<version>` Raw Output: message:"Pin versions in apk add. Instead of `apk add <package>` use `apk add <package>=<version>`" location:{path:"Dockerfile" range:{start:{line:8 column:1}}} severity:WARNING source:{name:"hadolint" url:"https://github.com/hadolint/hadolint"} code:{value:"DL3018" url:"https://github.com/hadolint/hadolint/wiki/DL3018"}

RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION}

# TODO: Install a linter and/or change docker image as you need.
RUN wget -O - -q https://git.io/misspell | sh -s -- -b /usr/local/bin/

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
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) 2020 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.
114 changes: 114 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# action-template

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

This is a template repository for [reviewdog](https://github.com/reviewdog/reviewdog) action with release automation.
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: update -->
```yaml
inputs:
github_token:
description: 'GITHUB_TOKEN'
default: '${{ github.token }}'
workdir:
description: 'Working directory relative to the root directory.'
default: '.'
### Flags for reviewdog ###
level:
description: 'Report level for reviewdog [info,warning,error]'
default: 'error'
reporter:
description: 'Reporter of reviewdog command [github-pr-check,github-check,github-pr-review].'
default: 'github-pr-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: update. replace `template` with the linter name -->

```yaml
name: reviewdog
on: [pull_request]
jobs:
# TODO: change `linter_name`.
linter_name:
name: runner / <linter-name>
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: reviewdog/action-template@v1
with:
github_token: ${{ secrets.github_token }}
# Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review].
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 template itself is integrated with reviewdog to run lints
which is useful for Docker container based actions.

![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-hadolint](https://github.com/reviewdog/action-hadolint)
- [reviewdog/action-misspell](https://github.com/reviewdog/action-misspell)

### 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)](https://github.com/reviewdog/action-template/pull/6)

0 comments on commit a56a83c

Please sign in to comment.