Sync JSON Schema Files from MaaFramework #252
This file contains hidden or 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: Sync JSON Schema Files from MaaFramework | |
| on: | |
| schedule: | |
| - cron: '10 0 * * *' # UTC 00:10 每天运行 | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write # 必须:允许创建 PR | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| jobs: | |
| check-repository: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_run: ${{ steps.check.outputs.should_run }} | |
| steps: | |
| - id: check | |
| run: | | |
| if [[ "${{ github.repository }}" == "sunyink/MFABD2" ]]; then | |
| echo "should_run=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "should_run=false" >> $GITHUB_OUTPUT | |
| fi | |
| sync-schema-files: | |
| needs: check-repository | |
| if: needs.check-repository.outputs.should_run == 'true' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # 在这里列出你需要同步的分支,假设你的开发分支叫 dev | |
| branch: [main, develop] | |
| steps: | |
| - name: Check Out Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ matrix.branch }} # 检出对应的目标分支 | |
| - name: Download JSON schema files from MaaFramework | |
| run: | | |
| echo "Syncing for branch: ${{ matrix.branch }}" | |
| mkdir -p deps/tools | |
| # 下载文件 | |
| curl -s -o deps/tools/interface.schema.json https://raw.githubusercontent.com/MaaXYZ/MaaFramework/main/tools/interface.schema.json | |
| curl -s -o deps/tools/interface_v2.schema.json https://raw.githubusercontent.com/MaaXYZ/MaaFramework/main/tools/interface_v2.schema.json | |
| curl -s -o deps/tools/interface_config.schema.json https://raw.githubusercontent.com/MaaXYZ/MaaFramework/main/tools/interface_config.schema.json | |
| curl -s -o deps/tools/pipeline.schema.json https://raw.githubusercontent.com/MaaXYZ/MaaFramework/main/tools/pipeline.schema.json | |
| echo "Downloaded files." | |
| # 使用 peter-evans/create-pull-request 自动处理变更检测和 PR 创建 | |
| # 它会自动对比下载的文件和仓库里的文件,如果没有变化,它什么都不做。 | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v6 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: chore/update schema files from MaaFramework | |
| committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | |
| author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | |
| signoff: false | |
| # PR 的分支名,加上分支后缀以区分 | |
| branch: chore/sync-schema-${{ matrix.branch }} | |
| delete-branch: true | |
| # PR 的目标分支 | |
| base: ${{ matrix.branch }} | |
| title: 'chore: update schema files from MaaFramework for ${{ matrix.branch }}' | |
| body: | | |
| Sync JSON schema files from MaaFramework. | |
| Target Branch: `${{ matrix.branch }}` | |
| Auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request) | |
| draft: false |