Skip to content

Update dependency @textlint/ast-node-types to v14 #1218

Update dependency @textlint/ast-node-types to v14

Update dependency @textlint/ast-node-types to v14 #1218

# SPDX-License-Identifier: MIT
name: Maintain code quality
on: [push, pull_request]
permissions:
contents: read
jobs:
lint:
name: Lint
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v3
with:
node-version: 16
cache: pnpm
- run: pnpm install
- name: Lint
id: lint
run: |
pnpm lint | cat > lint.log
exit_code=${PIPESTATUS[0]}
cat lint.log
echo "::set-output name=stdout::$(jq -sR . lint.log)"
exit $exit_code
- name: Send failure message to Discord with embed
uses: sarisia/actions-status-discord@v1
if: failure()
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
title: Lint でエラーが発生しました。今すぐ修整してください!
url: "${{ github.server_url }}/${{ github.repository }}/\
actions/runs/${{ github.run_id }}"
description: |-
```
${{ fromJson(steps.lint.outputs.stdout) }}
```
color: 0xff3333
username: GitHub Actions
avatar_url: https://github.com/actions.png
- name: Send failure mention to Discord
uses: actions/github-script@v6
if: failure()
env:
ACTOR: ${{ github.actor }}
JOB_URL: "${{ github.server_url }}/${{ github.repository }}/\
actions/runs/${{ github.run_id }}"
WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
USER_ID: ${{ secrets.DISCORD_USER_ID }}
with:
script: |
// prepare
const { ACTOR, JOB_URL, WEBHOOK, USER_ID } = process.env;
if (!USER_ID) return;
const userId = JSON.parse(USER_ID)[ACTOR];
if (!userId || userId.constructor.name === "Function") return;
// send
const https = require("https");
WEBHOOK.split("\n").forEach((url) => {
const request = https.request(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
});
const body = JSON.stringify({
username: "GitHub Actions",
avatar_url: "https://github.com/actions.png",
content: `<@${userId}> ` +
"Lint でエラーが発生しました。今すぐ修整してください!\n" +
"バグによるエラーの場合は `Re-run` で再実行してください。\n" +
JOB_URL
});
request.write(body);
request.end();
});
test:
name: Test
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v3
with:
node-version: 16
cache: pnpm
- run: pnpm install
- name: Test
run: pnpm test