forked from misskey-dev/misskey
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Misskey js autogen check improvements (misskey-dev#14652)
* ci: Make failure if misskey js autogen detected changes * ci: set persist-credentials
- Loading branch information
Showing
1 changed file
with
139 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
name: Check Misskey JS autogen | ||
|
||
on: | ||
pull_request_target: | ||
branches: | ||
- master | ||
- develop | ||
- improve-misskey-js-autogen-check | ||
paths: | ||
- packages/backend/** | ||
|
||
jobs: | ||
# pull_request_target safety: permissions: read-all, and there are no secrets used in this job | ||
generate-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/[email protected] | ||
with: | ||
submodules: true | ||
persist-credentials: false | ||
ref: refs/pull/${{ github.event.pull_request.number }}/merge | ||
|
||
- name: setup pnpm | ||
uses: pnpm/action-setup@v4 | ||
|
||
- name: setup node | ||
id: setup-node | ||
uses: actions/[email protected] | ||
with: | ||
node-version-file: '.node-version' | ||
cache: pnpm | ||
|
||
- name: install dependencies | ||
run: pnpm i --frozen-lockfile | ||
|
||
# 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 | ||
with: | ||
name: generated-misskey-js | ||
path: packages/misskey-js/generator/built/autogen | ||
|
||
# pull_request_target safety: permissions: read-all, and no user codes are executed | ||
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/[email protected] | ||
with: | ||
submodules: true | ||
persist-credentials: false | ||
ref: refs/pull/${{ github.event.pull_request.number }}/merge | ||
|
||
- name: Upload From Merged | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: actual-misskey-js | ||
path: packages/misskey-js/src/autogen | ||
|
||
# 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 | ||
|
||
- 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 | ||
if [ -s misskey-js.diff ]; then | ||
echo "changes=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "changes=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Print full diff | ||
run: cat ./misskey-js.diff | ||
|
||
- name: send message | ||
if: steps.check-changes.outputs.changes == 'true' | ||
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 | ||
if: steps.check-changes.outputs.changes == 'false' | ||
uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
comment_tag: check-misskey-js-autogen | ||
mode: delete | ||
message: "Thank you!" | ||
create_if_not_exists: false | ||
|
||
- name: Make failure if changes are detected | ||
if: steps.check-changes.outputs.changes == 'true' | ||
run: exit 1 |