Skip to content

コントロールパネルの権限強化 #5

コントロールパネルの権限強化

コントロールパネルの権限強化 #5

name: Check SPDX-License-Identifier
on:
push:
branches:
- stream
paths:
- .github/workflows/check-spdx-license-id.yaml
- cypress/e2e/**/*
- packages/**/*
- scripts/**/*
pull_request_target:
branches:
- stream
paths:
- cypress/e2e/**/*
- packages/**/*
- scripts/**/*
permissions:
contents: read
jobs:
pre-checkout:
name: Pre checkout
uses: ./.github/workflows/pre-checkout.yaml
check-spdx-license-id:
name: Check SPDX-License-Identifier
runs-on: ubuntu-22.04
needs:
- pre-checkout
steps:
- name: Checkout
uses: actions/[email protected]
with:
persist-credentials: false
ref: ${{ needs.pre-checkout.outputs.sha }}
fetch-depth: 1
- name: Check SPDX-License-Identifier
run: |
counter=0
search() {
local directory="$1"
if [[ ! -d "$directory" ]]; then
return 0
fi
find "$directory" -type f \
\( \
-name '*.html' -or \
-name '*.scss' -or \
-name '*.css' -or \
-name '*.vue' \
\) -or \
\( \
\( \
-name '*.ts' -or \
-name '*.js' -or \
-name '*.mjs' -or \
-name '*.cjs' \
\) -and \( \
-not -name '*.config.*' \
\) \
\)
}
check() {
local file="$1"
if ! (
grep -q 'SPDX-FileCopyrightText: ' "$file" &&
grep -q 'SPDX-License-Identifier: ' "$file"
); then
echo "::error file=${file},line=0::Missing SPDX-License-Identifier"
((counter++))
fi
}
directories=(
'cypress/e2e'
'packages/backend/migration'
'packages/backend/src'
'packages/backend/test'
'packages/backend/test-federation'
'packages/backend/test-server'
'packages/frontend/.storybook'
'packages/frontend/@types'
'packages/frontend/lib'
'packages/frontend/public'
'packages/frontend/src'
'packages/frontend/test'
'packages/frontend-embed/@types'
'packages/frontend-embed/src'
'packages/frontend-shared/@types'
'packages/frontend-shared/js'
'packages/misskey-bubble-game/src'
'packages/misskey-reversi/src'
'packages/sw/src'
'scripts'
)
for directory in "${directories[@]}"; do
for file in $(search "$directory"); do
check "$file"
done
done
if [ "$counter" -gt 0 ]; then
echo "::error::SPDX-License-Identifier is missing in ${counter} file(s)."
exit 1
else
echo '::notice::SPDX-License-Identifier is certainly described in all target file(s)!'
exit 0
fi