diff --git a/.github/workflows/merge.yaml b/.github/workflows/merge.yaml index 07accf7..e7e1526 100644 --- a/.github/workflows/merge.yaml +++ b/.github/workflows/merge.yaml @@ -25,81 +25,23 @@ jobs: steps: - name: "Request review from @ergebnis-bot" - uses: "actions/github-script@v5" + uses: "ergebnis/.github/actions/github/pull-request/request-review@1.3.2" with: github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" - script: | - const pullRequest = context.payload.workflow_run.pull_requests[0]; - - const reviewers = [ - "ergebnis-bot", - ]; - - try { - await github.rest.pulls.requestReviewers({ - owner: context.repo.owner, - pull_number: pullRequest.number, - repo: context.repo.repo, - reviewers: reviewers, - }); - } catch (error) { - core.setFailed(error.message); - } + reviewer: "ergebnis-bot" - name: "Assign @ergebnis-bot" - uses: "actions/github-script@v5" + uses: "ergebnis/.github/actions/github/pull-request/add-assignee@1.3.2" with: github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" - script: | - const pullRequest = context.payload.workflow_run.pull_requests[0]; - - const assignees = [ - "ergebnis-bot", - ]; - - try { - await github.rest.issues.addAssignees({ - assignees: assignees, - issue_number: pullRequest.number, - owner: context.repo.owner, - repo: context.repo.repo, - }); - } catch (error) { - core.setFailed(error.message); - } + assignee: "ergebnis-bot" - name: "Approve pull request" - uses: "actions/github-script@v5" + uses: "ergebnis/.github/actions/github/pull-request/approve@1.3.2" with: github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" - script: | - const pullRequest = context.payload.workflow_run.pull_requests[0]; - - try { - await github.rest.pulls.createReview({ - event: "APPROVE", - owner: context.repo.owner, - pull_number: pullRequest.number, - repo: context.repo.repo, - }); - } catch (error) { - core.setFailed(error.message); - } - name: "Merge pull request" - uses: "actions/github-script@v5" + uses: "ergebnis/.github/actions/github/pull-request/merge@1.3.2" with: github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" - script: | - const pullRequest = context.payload.workflow_run.pull_requests[0]; - - try { - await github.rest.pulls.merge({ - merge_method: "merge", - owner: context.repo.owner, - pull_number: pullRequest.number, - repo: context.repo.repo, - }); - } catch (error) { - core.setFailed(error.message); - } diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 318dd2d..5a18b72 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -14,24 +14,7 @@ jobs: runs-on: "ubuntu-latest" steps: - - name: "Determine tag" - run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV" - - name: "Create release" - uses: "actions/github-script@v5" + uses: "ergebnis/.github/actions/github/release/create@1.3.2" with: github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" - script: | - try { - await github.rest.repos.createRelease({ - draft: false, - generate_release_notes: true, - name: process.env.RELEASE_TAG, - owner: context.repo.owner, - prerelease: false, - repo: context.repo.repo, - tag_name: process.env.RELEASE_TAG, - }); - } catch (error) { - core.setFailed(error.message); - } diff --git a/.github/workflows/triage.yaml b/.github/workflows/triage.yaml index a1ba09b..39be0e6 100644 --- a/.github/workflows/triage.yaml +++ b/.github/workflows/triage.yaml @@ -15,40 +15,6 @@ jobs: steps: - name: "Add labels based on branch name" - uses: "actions/github-script@v5" + uses: "ergebnis/.github/actions/github/pull-request/add-label-based-on-branch-name@1.3.2" with: github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" - script: | - const branchPrefixLabels = { - feature: "enhancement", - fix: "bug", - }; - - const pullRequest = context.payload.pull_request; - - const branchName = pullRequest.head.ref; - - const matches = branchName.match(new RegExp('^([^/]+)\/')); - - if (!matches instanceof Array) { - return; - } - - if (!branchPrefixLabels.hasOwnProperty(matches[1])) { - return; - } - - const label = branchPrefixLabels[matches[1]]; - - try { - await github.rest.issues.addLabels({ - issue_number: pullRequest.number, - labels: [ - label, - ], - owner: context.repo.owner, - repo: context.repo.repo, - }); - } catch (error) { - core.setFailed(error.message); - }