From 34f82b01dff0b4244ab654577b60e3692d2222ff Mon Sep 17 00:00:00 2001 From: huchenlei Date: Sat, 13 Jul 2024 19:07:59 -0400 Subject: [PATCH 1/3] Add front end change guard --- .github/workflows/front-end-guard.yml | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/front-end-guard.yml diff --git a/.github/workflows/front-end-guard.yml b/.github/workflows/front-end-guard.yml new file mode 100644 index 000000000000..0ae9f5dd59e4 --- /dev/null +++ b/.github/workflows/front-end-guard.yml @@ -0,0 +1,38 @@ +# Guard any changes under web/ directory + +on: + pull_request: + branches: + - main + - master + paths: + - "web/**" + +jobs: + commentIfWebChanges: + runs-on: ubuntu-latest + if: ${{ !contains(github.event.pull_request.labels.*.name, 'Direct FrontEnd Change') }} + steps: + - name: Post comment on PR and apply label + uses: actions/github-script@v6 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const issue_number = context.issue.number; + + // Add comment + const message = "No direct changes are allowed in the web/ directory." + "Please submit the change to https://github.com/Comfy-Org/ComfyUI_frontend"; + github.rest.issues.createComment({ + issue_number: issue_number, + owner: context.repo.owner, + repo: context.repo.repo, + body: message + }); + // Apply label + github.rest.issues.addLabels({ + issue_number: issue_number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['Direct FrontEnd Change'] + }); From 36d8efd58547704d4086d2179e7dcd0f2da8ada5 Mon Sep 17 00:00:00 2001 From: huchenlei Date: Tue, 16 Jul 2024 21:30:36 -0400 Subject: [PATCH 2/3] Add permission --- .github/workflows/front-end-guard.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/front-end-guard.yml b/.github/workflows/front-end-guard.yml index 0ae9f5dd59e4..79d02f3d7758 100644 --- a/.github/workflows/front-end-guard.yml +++ b/.github/workflows/front-end-guard.yml @@ -12,6 +12,8 @@ jobs: commentIfWebChanges: runs-on: ubuntu-latest if: ${{ !contains(github.event.pull_request.labels.*.name, 'Direct FrontEnd Change') }} + permissions: + pull-requests: "write" steps: - name: Post comment on PR and apply label uses: actions/github-script@v6 @@ -22,7 +24,7 @@ jobs: // Add comment const message = "No direct changes are allowed in the web/ directory." - "Please submit the change to https://github.com/Comfy-Org/ComfyUI_frontend"; + "Please submit changes to https://github.com/Comfy-Org/ComfyUI_frontend instead"; github.rest.issues.createComment({ issue_number: issue_number, owner: context.repo.owner, From 7a1c4598e75dcae5dbcc48d5cec88dce381a1bbd Mon Sep 17 00:00:00 2001 From: huchenlei Date: Tue, 16 Jul 2024 21:43:40 -0400 Subject: [PATCH 3/3] nit --- .github/workflows/front-end-guard.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/front-end-guard.yml b/.github/workflows/front-end-guard.yml index 79d02f3d7758..0c3c039e8f0f 100644 --- a/.github/workflows/front-end-guard.yml +++ b/.github/workflows/front-end-guard.yml @@ -23,8 +23,7 @@ jobs: const issue_number = context.issue.number; // Add comment - const message = "No direct changes are allowed in the web/ directory." - "Please submit changes to https://github.com/Comfy-Org/ComfyUI_frontend instead"; + const message = "No direct changes are allowed in the web/ directory. Please submit changes to https://github.com/Comfy-Org/ComfyUI_frontend instead"; github.rest.issues.createComment({ issue_number: issue_number, owner: context.repo.owner,