Skip to content

Commit

Permalink
feat: Create action.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ginokent committed Jan 6, 2025
1 parent ecf579b commit 748060e
Show file tree
Hide file tree
Showing 12 changed files with 737 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ref: https://docs.github.com/ja/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-code-owners
* @hakadoriya/owner
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "11:00"
timezone: "Asia/Tokyo"
commit-message:
prefix: "ci(github-actions): "
labels:
- "ci"
assignees:
- "hakadoriya/owner"
reviewers:
- "hakadoriya/owner"
groups:
dependencies:
patterns:
- "*"
31 changes: 31 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!-- markdownlint-disable MD004 MD041 -->

## Ticket / Issue Number

> **Note**
> *Please fill in the ticket or issue number.*
> > Example:
> >
> > #1
## What's changed

> **Note**
> *Please explain what changes this pull request will make.*
> > Example:
> >
> > - Added functionality to perform 'bar' on 'foo'.
## Check List

- [ ] Assign reviewers
- [ ] Assign assignees
- [ ] Assign labels
- [ ] Add appropriate test cases

## Remark

> **Note**
> *Please provide additional remarks if necessary.*
<!-- markdownlint-enable MD004 MD041 -->
38 changes: 38 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# https://docs.github.com/ja/repositories/releasing-projects-on-github/automatically-generated-release-notes
changelog:
categories:
- title: "💥 BREAKING CHANGES"
labels:
- BREAKING CHANGE
- title: "⬆️ Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)"
labels:
- build
- dependencies
- title: "👷 Changes to our CI configuration files and scripts (examples: CircleCi, SauceLabs)"
labels:
- ci
- title: "📝 Documentation only changes"
labels:
- docs
- title: "✨ A new feature"
labels:
- feat
- title: "🐛 A bug fix"
labels:
- fix
- title: "⚡️ A code change that improves performance"
labels:
- perf
- title: "♻️ A code change that neither fixes a bug nor adds a feature"
labels:
- refactor
- title: "✅ Adding missing tests or correcting existing tests"
labels:
- test
- title: "🚨 Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)"
labels:
- style
- title: "🧑‍💻 Changes to the build process or auxiliary tools and libraries such as documentation generation"
labels:
- chore
- "*"
20 changes: 20 additions & 0 deletions .github/workflows/auto-assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: auto-assign

on:
pull_request:
types:
- opened
- ready_for_review
- reopened

jobs:
auto-assign:
if: github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]'
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- if: ${{ toJSON(github.event.pull_request.assignees) == '[]' }}
env:
GH_TOKEN: ${{ github.token }}
run: |
gh pr --repo ${{ github.repository }} edit ${{ github.event.pull_request.number }} --add-assignee "${{ github.event.pull_request.user.login }}"
32 changes: 32 additions & 0 deletions .github/workflows/example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: example

on:
push:
# NO paths filter
pull_request:
# NO paths filter
workflow_dispatch:

jobs:
missing-final-newline:
runs-on: ubuntu-latest
outputs:
missing: ${{ steps.missing-final-newline.outputs.missing }}
missing-files: ${{ steps.missing-final-newline.outputs.missing-files }}
steps:
- uses: hakadoriya/github-actions-missing-final-newline@develop
id: missing-final-newline
with:
paths: |-
^action.yml
# > Note: A job that is skipped will report its status as "Success".
# > It will not prevent a pull request from merging, even if it is a required check.
# ref. https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution#overview
missing:
runs-on: ubuntu-latest
needs: missing-final-newline
if: ${{ needs.missing-final-newline.outputs.missing == 'true' }}
steps:
- name: "if not skip"
run: |
echo "needs.missing-final-newline.outputs.missing-files: ${{ needs.missing-final-newline.outputs.missing-files }}"
80 changes: 80 additions & 0 deletions .github/workflows/label-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: label-checker

# # Dependabot
# gh label create --force "dependencies" --description "Pull requests that update a dependency file" --color 0366D6
# gh label create --force "go" --description "Pull requests that update Go code" --color 16E2E2
# gh label create --force "github_actions" --description "Pull requests that update GitHub Actions code" --color 000000
# gh label create --force "docker" --description "Pull requests that update Docker code" --color 21CEFF

# # Renovate
# gh label create --force "renovate" --description "Renovate" --color 009485

# # Commit prefix
# gh label create --force "BREAKING CHANGE" --description "BREAKING CHANGES" --color FF0303
# gh label create --force "build" --description "Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)" --color 5319E7
# gh label create --force "ci" --description "Changes to our CI configuration files and scripts (examples: CircleCi, SauceLabs)" --color 53C4EE
# gh label create --force "docs" --description "Documentation only changes" --color 1B3E44
# gh label create --force "feat" --description "A new feature" --color 0EAA80
# gh label create --force "fix" --description "A bug fix" --color 1D76DB
# gh label create --force "perf" --description "A code change that improves performance" --color A2EEEF
# gh label create --force "refactor" --description "A code change that neither fixes a bug nor adds a feature" --color C5DEF5
# gh label create --force "test" --description "Adding missing tests or correcting existing tests" --color 1D76DB
# gh label create --force "chore" --description "Changes to the build process or auxiliary tools and libraries such as documentation generation" --color 20313F

on:
pull_request:
types:
- opened
- edited
- labeled
- unlabeled
- ready_for_review
- reopened
- synchronize

env:
LABELS: "BREAKING CHANGE,build,ci,docs,feat,fix,perf,refactor,test,chore"

jobs:
label-checker:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
id-token: write
contents: read
pull-requests: write # required to add labels
statuses: read
checks: read
repository-projects: read
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }} # needed for gh pr view
- name: Check labels
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
# Check labels
set -Eeuo pipefail -x
# If any of the labels are present, exit with success
if [[ -n "$(gh pr view --json labels --jq ".labels[].name" | grep -E "^($(tr , "|" <<<"${LABELS:?}"))$")" ]]; then
exit 0
fi
# Add labels based on PR title
GH_PR_TITLE=$(gh pr view --json title --jq .title)
gh label list --json name --jq ".[].name" | while read -r LINE; do
awk -F: "/^${LINE-}(\([^\)]+\))?:/ {print \$1}" <<<"${GH_PR_TITLE:?}" | grep -Eo "^${LINE:?}" || true # NOTE: Ignore the return value of grep because we just want to output the string
done | xargs -t -I{} gh pr edit --add-label {}
# If any of the labels are present, exit with success
while read -r LINE; do
if grep -E "^($(tr , "|" <<<"${LABELS:?}"))$" <<<"${LINE-}"; then
exit 0
fi
done <<<"$(gh pr view --json labels --jq ".labels[].name")"
# If none of the labels are present, exit with error
exit 1
23 changes: 23 additions & 0 deletions .github/workflows/task-list-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: task-list-checker

on:
pull_request:
types:
- opened
- edited
- ready_for_review
- reopened
- synchronize

jobs:
task-list-checker:
if: github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
pull-requests: read
steps:
- uses: hakadoriya/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
46 changes: 46 additions & 0 deletions .github/workflows/typo-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: typo-checker
# ^^^^^^^^^^^^
# https://github.com/organization/repository/workflows/typo-checker/badge.svg
# ^^^^^^^^^^^^

on:
pull_request:
workflow_dispatch:
inputs: {}

# NOTE: If commit & push continuously, cancel the workflow other than the latest commit.
concurrency:
group: ${{ github.workflow }}-${{ github.base_ref }}-${{ github.head_ref }}-${{ github.ref }}
cancel-in-progress: true

permissions:
id-token: write
contents: read

env:
WORKDIR: .

defaults:
run:
shell: bash

jobs:
typo-checker: # NOTE: for Branch protection rule `Status checks that are required.`
runs-on: ubuntu-latest # ref. https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
steps:
- uses: actions/checkout@v4
- name: DEBUG
shell: bash
run: |
cat <<'DEBUG_DOC'
== DEBUG =======================================================
github.ref: ${{ github.ref }}
github.event_name: ${{ github.event_name }}
-- toJSON(github.event.inputs) ---------------------------------
${{ toJSON(github.event.inputs) }}
-- toJSON(github) ----------------------------------------------
${{ toJSON(github) }}
================================================================
DEBUG_DOC
- name: Check spelling
uses: crate-ci/typos@master
Loading

0 comments on commit 748060e

Please sign in to comment.