diff --git a/.github/workflows/prefill-pr.yml b/.github/workflows/prefill-pr.yml new file mode 100644 index 00000000..950badfa --- /dev/null +++ b/.github/workflows/prefill-pr.yml @@ -0,0 +1,36 @@ +name: Prefill PR Body + +on: + pull_request: + types: [opened] + +permissions: + pull-requests: write + +jobs: + update-pr: + runs-on: ubuntu-latest + + steps: + - name: Update PR body + uses: actions/github-script@v7 + with: + script: | + const MARKER = ""; + + const currentBody = context.payload.pull_request.body || ""; + if (currentBody.includes(MARKER)) return; + + const branch = encodeURIComponent(context.payload.pull_request.head.ref); + const yamatoUrl = "https://yamato.ds.unity3d.com/project/277/branch/" + branch + "/recent-jobs"; + + const yamatoBadge = "[![Yamato CI](https://img.shields.io/badge/Yamato-CI-blue?logo=unity&logoColor=white)](" + yamatoUrl + ")"; + + const buttons = MARKER + "\n" + yamatoBadge + "\n" + MARKER; + + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + body: `${buttons}\n\n${currentBody}` + }); \ No newline at end of file