Skip to content
Merged
38 changes: 32 additions & 6 deletions .github/workflows/pr-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,37 @@ on:
branches:
- release
- pg
types:
- labeled
types: [ labeled, synchronize ]

jobs:
check-label:
runs-on: ubuntu-latest
outputs:
ok_to_test: ${{ steps.checkLabel.outputs.ok_to_test }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check PR Label
id: checkLabel
uses: actions/github-script@v7
with:
# This script will check if the PR has ok-to-test label.
# To avoid being dependent on the event which triggered this workflow,
# we will always get the pull request labels directly from the context
# It will later set the output to be "true" or "false".
script: |
const labels = context.payload.pull_request.labels.map(label => label.name);
if (labels.includes("ok-to-test")) {
console.log("Label 'ok-to-test' is present");
core.setOutput("ok_to_test", "true");
} else {
console.log("Label 'ok-to-test' is not present");
core.setOutput("ok_to_test", "false");
}
parse-tags:
needs: [ check-label ]
runs-on: ubuntu-latest
if: github.event.label.name == 'ok-to-test'
permissions:
pull-requests: write
defaults:
Expand All @@ -27,7 +51,7 @@ jobs:
- name: Checkout the head commit of the branch
uses: actions/checkout@v4
with:
repository: appsmithorg/appsmith
repository: appsmithorg/appsmith

# Reads the PR description to retrieve the /ok-to-test or, if that's absent, the /test command
- name: Read tags from PR description
Expand All @@ -37,7 +61,9 @@ jobs:
NODE_PATH: "${{ github.workspace }}/.github/workflows/scripts"
with:
script: |
require("test-tag-parser.js")({core, context, github})
if(${{ steps.checkLabel.outputs.ok_to_test == 'true' }}) {
require("test-tag-parser.js")({core, context, github})
}

# In case of a run with all test cases, allocate a larger matrix
- name: Check if @tag.All is present in tags
Expand Down Expand Up @@ -72,7 +98,7 @@ jobs:

# Call the workflow to run Cypress tests
perform-test:
needs: [parse-tags]
needs: [ parse-tags ]
if: success()
uses: ./.github/workflows/pr-cypress.yml
secrets: inherit
Expand Down