2024-01-13 22:30:21 -08:00
|
|
|
name: Check Misskey JS autogen
|
|
|
|
|
|
|
|
on:
|
2024-01-22 13:35:15 -08:00
|
|
|
pull_request_target:
|
2024-01-13 22:30:21 -08:00
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
- develop
|
2024-04-15 06:11:17 -07:00
|
|
|
- improve-misskey-js-autogen-check
|
2024-01-13 22:30:21 -08:00
|
|
|
paths:
|
|
|
|
- packages/backend/**
|
|
|
|
|
|
|
|
jobs:
|
2024-04-15 06:11:17 -07:00
|
|
|
# pull_request_target safety: permissions: read-all, and there are no secrets used in this job
|
|
|
|
generate-misskey-js:
|
2024-01-13 22:30:21 -08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
2024-04-15 06:11:17 -07:00
|
|
|
contents: read
|
|
|
|
if: ${{ github.event.pull_request.mergeable == null || github.event.pull_request.mergeable == true }}
|
2024-01-13 22:30:21 -08:00
|
|
|
steps:
|
|
|
|
- name: checkout
|
2024-02-15 23:32:49 -08:00
|
|
|
uses: actions/checkout@v4.1.1
|
2024-01-13 22:30:21 -08:00
|
|
|
with:
|
|
|
|
submodules: true
|
2024-04-15 06:11:17 -07:00
|
|
|
ref: refs/pull/${{ github.event.pull_request.number }}/merge
|
2024-01-13 22:30:21 -08:00
|
|
|
|
|
|
|
- name: setup pnpm
|
2024-02-09 00:05:25 -08:00
|
|
|
uses: pnpm/action-setup@v3
|
2024-01-13 22:30:21 -08:00
|
|
|
with:
|
2024-05-04 04:56:14 -07:00
|
|
|
version: 9
|
2024-01-13 22:30:21 -08:00
|
|
|
|
|
|
|
- name: setup node
|
|
|
|
id: setup-node
|
2024-02-15 23:33:01 -08:00
|
|
|
uses: actions/setup-node@v4.0.2
|
2024-01-13 22:30:21 -08:00
|
|
|
with:
|
|
|
|
node-version-file: '.node-version'
|
|
|
|
cache: pnpm
|
|
|
|
|
|
|
|
- name: install dependencies
|
|
|
|
run: pnpm i --frozen-lockfile
|
|
|
|
|
2024-04-15 06:11:17 -07:00
|
|
|
# generate api.json
|
|
|
|
- name: Copy Config
|
|
|
|
run: cp .config/example.yml .config/default.yml
|
|
|
|
- name: Build
|
|
|
|
run: pnpm build
|
|
|
|
- name: Generate API JSON
|
|
|
|
run: pnpm --filter backend generate-api-json
|
|
|
|
|
|
|
|
# build misskey js
|
|
|
|
- name: Build misskey-js
|
|
|
|
run: |-
|
|
|
|
cp packages/backend/built/api.json packages/misskey-js/generator/api.json
|
|
|
|
pnpm run --filter misskey-js-type-generator generate
|
|
|
|
|
|
|
|
# packages/misskey-js/generator/built/autogen
|
|
|
|
- name: Upload Generated
|
|
|
|
uses: actions/upload-artifact@v4
|
2024-01-13 22:30:21 -08:00
|
|
|
with:
|
2024-04-15 06:11:17 -07:00
|
|
|
name: generated-misskey-js
|
|
|
|
path: packages/misskey-js/generator/built/autogen
|
2024-01-13 22:30:21 -08:00
|
|
|
|
2024-04-15 06:11:17 -07:00
|
|
|
# pull_request_target safety: permissions: read-all, and there are no secrets used in this job
|
|
|
|
get-actual-misskey-js:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
if: ${{ github.event.pull_request.mergeable == null || github.event.pull_request.mergeable == true }}
|
|
|
|
steps:
|
|
|
|
- name: checkout
|
|
|
|
uses: actions/checkout@v4.1.1
|
2024-01-13 22:30:21 -08:00
|
|
|
with:
|
2024-04-15 06:11:17 -07:00
|
|
|
submodules: true
|
|
|
|
ref: refs/pull/${{ github.event.pull_request.number }}/merge
|
2024-01-13 22:30:21 -08:00
|
|
|
|
2024-04-15 06:11:17 -07:00
|
|
|
- name: Upload From Merged
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
with:
|
|
|
|
name: actual-misskey-js
|
|
|
|
path: packages/misskey-js/src/autogen
|
2024-01-22 13:35:15 -08:00
|
|
|
|
2024-04-15 06:11:17 -07:00
|
|
|
# pull_request_target safety: nothing is cloned from repository
|
|
|
|
comment-misskey-js-autogen:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: [generate-misskey-js, get-actual-misskey-js]
|
|
|
|
permissions:
|
|
|
|
pull-requests: write
|
|
|
|
steps:
|
|
|
|
- name: download generated-misskey-js
|
|
|
|
uses: actions/download-artifact@v4
|
|
|
|
with:
|
|
|
|
name: generated-misskey-js
|
|
|
|
path: misskey-js-generated
|
2024-01-22 13:35:15 -08:00
|
|
|
|
2024-04-15 06:11:17 -07:00
|
|
|
- name: download actual-misskey-js
|
|
|
|
uses: actions/download-artifact@v4
|
|
|
|
with:
|
|
|
|
name: actual-misskey-js
|
|
|
|
path: misskey-js-actual
|
|
|
|
|
|
|
|
- name: check misskey-js changes
|
|
|
|
id: check-changes
|
|
|
|
run: |
|
|
|
|
diff -r -u --label=generated --label=on-tree ./misskey-js-generated ./misskey-js-actual > misskey-js.diff || true
|
2024-01-13 22:30:21 -08:00
|
|
|
|
2024-04-15 06:11:17 -07:00
|
|
|
if [ -s misskey-js.diff ]; then
|
|
|
|
echo "changes=true" >> $GITHUB_OUTPUT
|
|
|
|
else
|
|
|
|
echo "changes=false" >> $GITHUB_OUTPUT
|
|
|
|
fi
|
2024-01-13 22:30:21 -08:00
|
|
|
|
2024-04-15 06:11:17 -07:00
|
|
|
- name: Print full diff
|
|
|
|
run: cat ./misskey-js.diff
|
2024-01-13 22:30:21 -08:00
|
|
|
|
|
|
|
- name: send message
|
2024-04-15 06:11:17 -07:00
|
|
|
if: steps.check-changes.outputs.changes == 'true'
|
2024-01-13 22:30:21 -08:00
|
|
|
uses: thollander/actions-comment-pull-request@v2
|
|
|
|
with:
|
|
|
|
comment_tag: check-misskey-js-autogen
|
|
|
|
message: |-
|
|
|
|
Thank you for sending us a great Pull Request! 👍
|
|
|
|
Please regenerate misskey-js type definitions! 🙏
|
|
|
|
|
|
|
|
example:
|
|
|
|
```sh
|
|
|
|
pnpm run build-misskey-js-with-types
|
|
|
|
```
|
|
|
|
|
|
|
|
- name: send message
|
2024-04-15 06:11:17 -07:00
|
|
|
if: steps.check-changes.outputs.changes == 'false'
|
2024-01-13 22:30:21 -08:00
|
|
|
uses: thollander/actions-comment-pull-request@v2
|
|
|
|
with:
|
|
|
|
comment_tag: check-misskey-js-autogen
|
|
|
|
mode: delete
|
|
|
|
message: "Thank you!"
|
2024-01-22 13:35:15 -08:00
|
|
|
create_if_not_exists: false
|