[Automated] Update NPM dependencies #5463
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'dependency-cruiser-report' | |
on: | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
report: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
fetch-depth: 0 | |
persist-credentials: false | |
submodules: true | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@v2 | |
- name: Install dependencies | |
run: bun install | |
- name: Run dependency-cruiser | |
run: | | |
files="$(git diff --name-only --diff-filter=AM origin/${{ github.base_ref }}...HEAD | grep -E "src/.*\.(js|cjs|mjs|jsx|ts|tsx)$" | tr '\n' ' ' | xargs)"; | |
formattedOption=$(echo "^$files" | sed 's/ /|^/g'); | |
echo $files; | |
if [[ $files == "" ]]; then | |
echo "特定のファイルに変更がないので終了します。" | |
exit 0 | |
fi | |
if [[ $files != "" ]]; then | |
bunx depcruise --cache -X "^node_modules" --max-depth 3 -T json --reaches $formattedOption $files > _temp.json | |
echo -e '\n' >> result.md | |
bunx depcruise-fmt -T markdown _temp.json >> result.md | |
echo -e '\n' >> result.md | |
echo -e '\n---\n' >> result.md | |
echo -e '\n<details>' >> result.md | |
echo -e '\n<summary>変更されたファイルの依存関係を可視化します。</summary>' >> result.md | |
echo -e '\n```mermaid' >> result.md | |
bunx depcruise-fmt -T mermaid _temp.json >> result.md | |
echo -e '\n```' >> result.md | |
echo -e '\n</details>' >> result.md | |
fi | |
echo "files=$files" >> $GITHUB_ENV | |
cat result.md | |
- name: Initial Markdown File | |
run: | | |
echo '<!-- dependency-cruiser report -->' > comment.md | |
echo '' >> comment.md | |
- name: Generate Markdown Text | |
run: | | |
if [[ "${{ env.files }}" != "" ]]; then | |
cat result.md >> comment.md | |
else | |
echo '依存関係を分析する対象のファイルがありませんでした。' >> comment.md | |
fi | |
- name: Write Comment (Use find-comment) | |
uses: peter-evans/find-comment@v3 | |
id: fc | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: 'github-actions[bot]' | |
body-includes: <!-- dependency-cruiser report --> | |
- name: Update Comment | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body-path: comment.md | |
edit-mode: replace | |
token: ${{ secrets.GITHUB_TOKEN }} |