Skip to content

Commit

Permalink
chore: update automerge.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
xiehan authored Nov 1, 2023
1 parent f78cc25 commit 12ba359
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions projenrc/automerge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { javascript } from "projen";
import { JobPermission } from "projen/lib/github/workflows-model";

/**
* Turns on GitHub's native automerge for PRs with the "automerge" label
* Enables GitHub's built-in automerge for PRs with the "automerge" label
*/
export class Automerge {
constructor(project: javascript.NodeProject) {
Expand All @@ -16,7 +16,7 @@ export class Automerge {
if (!workflow) throw new Error("no workflow defined");

workflow.on({
pullRequest: {
pullRequestTarget: {
types: [
"opened",
"labeled",
Expand All @@ -29,6 +29,7 @@ export class Automerge {

(workflow.concurrency as any) = "${{ github.workflow }}-${{ github.ref }}";

const maintainerStatuses = `fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]')`;
workflow.addJobs({
automerge: {
runsOn: ["ubuntu-latest"],
Expand All @@ -39,7 +40,8 @@ export class Automerge {
uses: "actions/checkout@v3",
},
{
name: "Turn on automerge for this PR",
name: "Turn on automerge for this PR by a trusted user or bot",
if: `github.event.pull_request.user.login == 'team-tf-cdk' || contains(${maintainerStatuses}, github.event.pull_request.author_association) || github.actor == 'dependabot[bot]'`,
run: "gh pr merge --auto --squash ${{ github.event.pull_request.number }}",
env: {
GH_TOKEN: "${{ secrets.PROJEN_GITHUB_TOKEN }}",
Expand Down

0 comments on commit 12ba359

Please sign in to comment.