mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-07-14 01:54:44 +02:00
85 lines
3.1 KiB
YAML
85 lines
3.1 KiB
YAML
name: Report API Diff
|
|
|
|
on:
|
|
workflow_run:
|
|
types: [completed]
|
|
workflows:
|
|
- Get api.json from Misskey # get-api-diff.yml
|
|
|
|
jobs:
|
|
compare-diff:
|
|
runs-on: ubuntu-latest
|
|
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
permissions:
|
|
actions: read
|
|
pull-requests: write
|
|
|
|
# api-artifact
|
|
steps:
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
pattern: api-artifact-*
|
|
path: artifacts
|
|
merge-multiple: true
|
|
github-token: ${{ github.token }}
|
|
repository: ${{ github.repository }}
|
|
run-id: ${{ github.event.workflow_run.id }}
|
|
- name: Check artifacts
|
|
run: ls -lh artifacts/
|
|
- name: Load PR Number
|
|
id: load-pr-num
|
|
run: echo "pr-number=$(cat artifacts/pr_number)" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Arrange json files
|
|
run: |
|
|
jq '.' ./artifacts/api-base.json > ./api-base.json
|
|
jq '.' ./artifacts/api-head.json > ./api-head.json
|
|
- name: Get diff of 2 files
|
|
run: diff -u --label=base --label=head ./api-base.json ./api-head.json | cat > api.json.diff
|
|
- name: Get full diff
|
|
run: diff --label=base --label=head --new-line-format='+%L' --old-line-format='-%L' --unchanged-line-format=' %L' ./api-base.json ./api-head.json | cat > api-full.json.diff
|
|
- name: Upload full diff to Artifact
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: api-artifact
|
|
path: |
|
|
api-full.json.diff
|
|
api-base.json
|
|
api-head.json
|
|
- id: out-diff
|
|
name: Build diff Comment
|
|
run: |
|
|
HEADER="このPRによるapi.jsonの差分"
|
|
FOOTER="[Get diff files from Workflow Page](https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID})"
|
|
DIFF_BYTES="$(stat ./api.json.diff -c '%s' | tr -d '\n')"
|
|
|
|
echo "$HEADER" > ./output.md
|
|
|
|
if (( "$DIFF_BYTES" <= 1 )); then
|
|
echo '差分はありません。' >> ./output.md
|
|
else
|
|
echo '<details>' >> ./output.md
|
|
echo '<summary>差分はこちら</summary>' >> ./output.md
|
|
echo >> ./output.md
|
|
echo '```diff' >> ./output.md
|
|
cat ./api.json.diff >> ./output.md
|
|
echo '```' >> ./output.md
|
|
echo '</details>' >> .output.md
|
|
fi
|
|
|
|
echo "$FOOTER" >> ./output.md
|
|
- uses: thollander/actions-comment-pull-request@v3
|
|
with:
|
|
pr-number: ${{ steps.load-pr-num.outputs.pr-number }}
|
|
comment-tag: show_diff
|
|
file-path: ./output.md
|
|
- name: Tell error to PR
|
|
uses: thollander/actions-comment-pull-request@v3
|
|
if: failure() && steps.load-pr-num.outputs.pr-number
|
|
with:
|
|
pr-number: ${{ steps.load-pr-num.outputs.pr-number }}
|
|
comment-tag: show_diff_error
|
|
message: |
|
|
api.jsonの差分作成中にエラーが発生しました。詳細は[Workflowのログ](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})を確認してください。
|