diff --git a/.github/workflows/compareNDandODbuilds.yml b/.github/workflows/compareNDandODbuilds.yml index bb61f1ba58cb..eae771c965d8 100644 --- a/.github/workflows/compareNDandODbuilds.yml +++ b/.github/workflows/compareNDandODbuilds.yml @@ -52,36 +52,13 @@ jobs: postGitHubCommentBuildStarted: - runs-on: ubuntu-latest - needs: [getBranchRef, getOldDotBranchRef] - steps: - - name: Add comment to ND PR - if: ${{ github.event.inputs.PULL_REQUEST_NUMBER != ''}} - uses: actions/github-script@v7 - with: - github-token: ${{ github.token }} - script: | - const workflowURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; - github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: ${{ github.event.inputs.PULL_REQUEST_NUMBER }}, - body: `🚧 @${{ github.actor }} has triggered build profiling. You can view the [workflow run here](${workflowURL}).` - }); - - - name: Add comment to OD PR - if: ${{ github.event.inputs.OLD_DOT_PULL_REQUEST_NUMBER != '' }} - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.OS_BOTIFY_TOKEN }} - script: | - const workflowURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; - github.rest.issues.createComment({ - owner: context.repo.owner, - repo: 'Mobile-Expensify', - issue_number: ${{ github.event.inputs.OLD_DOT_PULL_REQUEST_NUMBER }}, - body: `🚧 @${{ github.actor }} has triggered build profiling. You can view the [workflow run here](${workflowURL}).` - }); + name: Post build started comment + uses: ./.github/workflows/postBuildStartedComment.yml + secrets: inherit + with: + APP_PULL_REQUEST_NUMBER: ${{ inputs.PULL_REQUEST_NUMBER }} + HYBRIDAPP_PULL_REQUEST_NUMBER: ${{ inputs.OLD_DOT_PULL_REQUEST_NUMBER }} + buildHybridAppAndroid: name: Build HybridApp Android diff --git a/.github/workflows/postBuildStartedComment.yml b/.github/workflows/postBuildStartedComment.yml new file mode 100644 index 000000000000..b56dba846f01 --- /dev/null +++ b/.github/workflows/postBuildStartedComment.yml @@ -0,0 +1,45 @@ +name: Post build has been started comment + +on: + workflow_call: + inputs: + APP_PULL_REQUEST_NUMBER: + description: Number of the Pull Request in the App repository where the comment will be posted + type: string + required: false + HYBRIDAPP_PULL_REQUEST_NUMBER: + description: Number of the Pull Request in the Mobile-Expensify repository where the comment will be posted + type: string + required: false + +jobs: + postGitHubCommentBuildStarted: + runs-on: ubuntu-latest + steps: + - name: Add build start comment to ND PR + if: ${{ inputs.APP_PULL_REQUEST_NUMBER != ''}} + uses: actions/github-script@v7 + with: + github-token: ${{ github.token }} + script: | + const workflowURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; + github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: ${{ inputs.APP_PULL_REQUEST_NUMBER }}, + body: `🚧 @${{ github.actor }} has triggered a test hybrid app build. You can view the [workflow run here](${workflowURL}).` + }); + + - name: Add build start comment to OD PR + if: ${{ inputs.HYBRIDAPP_PULL_REQUEST_NUMBER != '' }} + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.OS_BOTIFY_TOKEN }} + script: | + const workflowURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; + github.rest.issues.createComment({ + owner: context.repo.owner, + repo: 'Mobile-Expensify', + issue_number: ${{ inputs.HYBRIDAPP_PULL_REQUEST_NUMBER }}, + body: `🚧 @${{ github.actor }} has triggered a test hybrid app build. You can view the [workflow run here](${workflowURL}).` + }); \ No newline at end of file diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index fc271e426e32..7c8d9eb8b0ff 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -55,21 +55,12 @@ jobs: GITHUB_TOKEN: ${{ github.token }} postGitHubCommentBuildStarted: - runs-on: ubuntu-latest + name: Post build started comment + uses: ./.github/workflows/postBuildStartedComment.yml needs: [prep] - steps: - - name: Add build start comment - uses: actions/github-script@v7 - with: - github-token: ${{ github.token }} - script: | - const workflowURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; - github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: process.env.PULL_REQUEST_NUMBER, - body: `🚧 @${{ github.actor }} has triggered a test build. You can view the [workflow run here](${workflowURL}).` - }); + secrets: inherit + with: + APP_PULL_REQUEST_NUMBER: ${{ github.event.number || github.event.inputs.PULL_REQUEST_NUMBER }} buildAndroid: name: Build Android app for testing diff --git a/.github/workflows/testBuildHybrid.yml b/.github/workflows/testBuildHybrid.yml index 048db47a2dc4..3f3b8c147671 100644 --- a/.github/workflows/testBuildHybrid.yml +++ b/.github/workflows/testBuildHybrid.yml @@ -110,36 +110,13 @@ jobs: postGitHubCommentBuildStarted: - runs-on: ubuntu-latest + name: Post build started comment + uses: ./.github/workflows/postBuildStartedComment.yml needs: [getNewDotRef, getOldDotPR, getOldDotRef] - steps: - - name: Add build start comment to ND PR - if: ${{ github.event.inputs.APP_PULL_REQUEST_NUMBER != ''}} - uses: actions/github-script@v7 - with: - github-token: ${{ github.token }} - script: | - const workflowURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; - github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: ${{ github.event.inputs.APP_PULL_REQUEST_NUMBER }}, - body: `🚧 @${{ github.actor }} has triggered a test hybrid app build. You can view the [workflow run here](${workflowURL}).` - }); - - - name: Add build start comment to OD PR - if: ${{ needs.getOldDotPR.outputs.OLD_DOT_PR != '' }} - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.OS_BOTIFY_TOKEN }} - script: | - const workflowURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; - github.rest.issues.createComment({ - owner: context.repo.owner, - repo: 'Mobile-Expensify', - issue_number: ${{ needs.getOldDotPR.outputs.OLD_DOT_PR }}, - body: `🚧 @${{ github.actor }} has triggered a test hybrid app build. You can view the [workflow run here](${workflowURL}).` - }); + secrets: inherit + with: + APP_PULL_REQUEST_NUMBER: ${{ inputs.APP_PULL_REQUEST_NUMBER }} + HYBRIDAPP_PULL_REQUEST_NUMBER: ${{ github.event.inputs.HYBRIDAPP_PULL_REQUEST_NUMBER || needs.getOldDotPR.outputs.OLD_DOT_PR }} androidHybrid: name: Build Android HybridApp