From 4a58c224a236c9baa711a40412fb0319ede92d69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Wed, 1 Jun 2022 15:56:26 +0200 Subject: [PATCH] Use babel/actions/create-pull-request --- .github/workflows/update-compat-data.yml | 46 ++++----------------- .github/workflows/update-parser-tests.yml | 49 ++++++----------------- 2 files changed, 20 insertions(+), 75 deletions(-) diff --git a/.github/workflows/update-compat-data.yml b/.github/workflows/update-compat-data.yml index 9e68a4dd3371..9d231290404c 100644 --- a/.github/workflows/update-compat-data.yml +++ b/.github/workflows/update-compat-data.yml @@ -37,42 +37,12 @@ jobs: git commit -am "chore: update compat data to ${{ steps.lastCommit.outputs.sha1 }}" git push --force origin update-compat-data - name: Create Pull Request - uses: actions/github-script@v4 + uses: babel/actions/create-pull-request@v2 with: - github-token: ${{ secrets.BOT_TOKEN }} - script: | - const base = process.env.GITHUB_REF.replace("refs/heads/", ""); - const requestParam = { - owner: context.repo.owner, - repo: context.repo.repo, - head: context.repo.owner + ":update-compat-data", - base: base, - state: "open" - }; - const result = await github.pulls.list(requestParam); - console.log("Open PR request: ", requestParam); - console.log("Open PR response: ", result); - const prs = result.data; - if (prs.length === 0) { - const requestParam = { - owner: context.repo.owner, - repo: context.repo.repo, - head: "update-compat-data", - base: base, - maintainer_can_modify: true, - title: "Update compat data", - body: "Update compat data to [${{ steps.lastCommit.outputs.sha1 }}](https://github.com/kangax/compat-table/commit/${{ steps.lastCommit.outputs.sha1 }}).", - }; - const result = await github.pulls.create(requestParam); - console.log("Create PR request: ", requestParam) - console.log("Create PR response: ", result); - - github.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: result.data.number, - labels: ["area: compat-data", "repo automation :robot:"] - }) - } - - + token: ${{ secrets.BOT_TOKEN }} + branch: update-compat-data + title: Update compat data + description: Update compat data to [${{ steps.lastCommit.outputs.sha1 }}](https://github.com/kangax/compat-table/commit/${{ steps.lastCommit.outputs.sha1 }}). + labels: | + area: compat-data + repo automation :robot: diff --git a/.github/workflows/update-parser-tests.yml b/.github/workflows/update-parser-tests.yml index 960aa4ab55a8..1fb0ff38ccbc 100644 --- a/.github/workflows/update-parser-tests.yml +++ b/.github/workflows/update-parser-tests.yml @@ -13,7 +13,7 @@ permissions: jobs: createPullRequest: permissions: - contents: write # for Git to git push + contents: write # for Git to git push runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -47,40 +47,15 @@ jobs: git commit -am "chore: update test262 to ${{ steps.test262.outputs.sha1 }}" git push --force origin update-test262-parser - name: Create Pull Request - uses: actions/github-script@v4 + uses: babel/actions/create-pull-request@v2 with: - github-token: ${{ secrets.BOT_TOKEN }} - script: | - const base = process.env.GITHUB_REF.replace("refs/heads/", ""); - const requestParam = { - owner: context.repo.owner, - repo: context.repo.repo, - head: context.repo.owner + ":update-test262-parser", - base: base, - state: "open" - }; - const result = await github.pulls.list(requestParam); - console.log("Open PR request: ", requestParam); - console.log("Open PR response: ", result); - const prs = result.data; - if (prs.length === 0) { - const requestParam = { - owner: context.repo.owner, - repo: context.repo.repo, - head: "update-test262-parser", - base: base, - maintainer_can_modify: true, - title: "Update test262", - body: "Update test262 to [${{ steps.test262.outputs.sha1 }}](https://github.com/tc39/test262/commit/${{ steps.test262.outputs.sha1 }}).", - }; - const result = await github.pulls.create(requestParam); - console.log("Create PR request: ", requestParam) - console.log("Create PR response: ", result); - - github.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: result.data.number, - labels: ["area: test262", "repo automation :robot:"] - }) - } + token: ${{ secrets.BOT_TOKEN }} + branch: update-test262-parser + commit-user: Babel Bot + commit-email: babel-bot@users.noreply.github.com + commit-title: chore: update test262 to ${{ steps.test262.outputs.sha1 }} + pr-title: Update test262 + pr-description: Update test262 to [${{ steps.test262.outputs.sha1 }}](https://github.com/tc39/test262/commit/${{ steps.test262.outputs.sha1 }}). + pr-labels: | + area: test262 + repo automation :robot: