内部のメディアプロキシ・サマリープロキシの動作を変更 #429
Workflow file for this run
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: Report API Diff | |
on: | |
pull_request: | |
branches: | |
- master | |
- develop | |
- develop-mame | |
paths: | |
- packages/backend/** | |
- packages/misskey-js/** | |
- .github/workflows/report-api-diff.yml | |
- .node-version | |
permissions: {} | |
jobs: | |
get-api-json: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
strategy: | |
matrix: | |
api-json-name: [api-base.json, api-head.json] | |
include: | |
- api-json-name: api-base.json | |
ref: ${{ github.base_ref }} | |
- api-json-name: api-head.json | |
ref: refs/pull/${{ github.event.number }}/merge | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
with: | |
ref: ${{ matrix.ref }} | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v4 | |
- name: Setup Node.js | |
uses: actions/[email protected] | |
with: | |
node-version-file: '.node-version' | |
cache: 'pnpm' | |
- name: Enable Corepack | |
run: corepack enable | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Check if lock file is not modified | |
run: git diff --exit-code pnpm-lock.yaml | |
- name: Copy config file | |
run: cp .config/example.yml .config/default.yml | |
- name: Pre-build | |
run: pnpm run build-pre | |
- name: Generate api.json | |
run: pnpm --filter backend run generate-api-json | |
- name: Copy api.json | |
run: cp packages/backend/built/api.json ${{ matrix.api-json-name }} | |
- name: Upload api.json | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.api-json-name }} | |
path: ${{ matrix.api-json-name }} | |
get-api-json-diff: | |
runs-on: ubuntu-latest | |
needs: get-api-json | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
merge-multiple: true | |
- 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@v4 | |
with: | |
name: api-full.json.diff | |
path: api-full.json.diff | |
- name: Build diff Comment | |
id: out-diff | |
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 | |
- name: Send comment | |
uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 | |
with: | |
pr_number: ${{ github.event.number }} | |
comment_tag: show_diff | |
filePath: ./output.md | |
- name: Tell error to PR | |
uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 | |
if: failure() && github.event.number | |
with: | |
pr_number: ${{ github.event.number }} | |
comment_tag: show_diff_error | |
message: | | |
api.jsonの差分作成中にエラーが発生しました。詳細は[Workflowのログ](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})を確認してください。 | |
- name: Tell no error to PR | |
if: ${{ !failure() }} | |
uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 | |
with: | |
comment_tag: show_diff_error | |
message: "api.jsonの差分作成は正常に行われました。" | |
create_if_not_exists: false |