From 755a0b9ef8b6478a3f8ec004d620f53cf6ecae3a Mon Sep 17 00:00:00 2001 From: rory Date: Fri, 20 Sep 2024 17:15:12 -0700 Subject: [PATCH 1/8] Create postDeployComments workflow --- .../markPullRequestsAsDeployed/action.yml | 5 +- .github/workflows/postDeployComments.yml | 125 ++++++++++++++++++ 2 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/postDeployComments.yml diff --git a/.github/actions/javascript/markPullRequestsAsDeployed/action.yml b/.github/actions/javascript/markPullRequestsAsDeployed/action.yml index f0ca77bdbf00..265dc07b3978 100644 --- a/.github/actions/javascript/markPullRequestsAsDeployed/action.yml +++ b/.github/actions/javascript/markPullRequestsAsDeployed/action.yml @@ -13,7 +13,7 @@ inputs: required: true GITHUB_TOKEN: description: "Github token for authentication" - required: true + required: false default: "${{ github.token }}" ANDROID: description: "Android job result ('success', 'failure', 'cancelled', or 'skipped')" @@ -27,6 +27,9 @@ inputs: WEB: description: "Web job result ('success', 'failure', 'cancelled', or 'skipped')" required: true + DATE: + description: "The date of deployment" + required: false runs: using: "node20" main: "./index.js" diff --git a/.github/workflows/postDeployComments.yml b/.github/workflows/postDeployComments.yml new file mode 100644 index 000000000000..144e03d7a043 --- /dev/null +++ b/.github/workflows/postDeployComments.yml @@ -0,0 +1,125 @@ +name: Post Deploy Comments + +on: + workflow_call: + inputs: + version: + description: The version that was deployed + required: true + type: string + env: + description: The environment that was deployed (staging or prod) + required: true + type: string + isCP: + description: Was the deploy a CP? + required: true + type: boolean + android: + description: Android deploy status + required: true + type: string + ios: + description: iOS deploy status + required: true + type: string + web: + description: Web deploy status + required: true + type: string + desktop: + description: Desktop deploy status + required: true + type: string + workflow_dispatch: + inputs: + version: + description: The version that was deployed + required: true + type: string + env: + description: The environment that was deployed (staging or prod) + required: true + type: choice + options: + - staging + - production + isCP: + description: Was the deploy a CP? + required: true + type: boolean + android: + description: Android deploy status + required: true + type: choice + options: + - success + - failure + - cancelled + - skipped + ios: + description: iOS deploy status + required: true + type: choice + options: + - success + - failure + - cancelled + - skipped + web: + description: Web deploy status + required: true + type: choice + options: + - success + - failure + - cancelled + - skipped + desktop: + description: Desktop deploy status + required: true + type: choice + options: + - success + - failure + - cancelled + - skipped + date: + description: The date when this deploy occurred + required: false + type: string + deployerNote: + description: Any additional note you want to include with the deploy comment + required: false + type: string + +jobs: + postDeployComments: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node + uses: ./.github/actions/composite/setupNode + + - name: Get pull request list + id: getPullRequestList + uses: ./.github/actions/javascript/getDeployPullRequestList + with: + TAG: ${{ inputs.version }} + GITHUB_TOKEN: ${{ github.token }} + IS_PRODUCTION_DEPLOY: ${{ inputs.env == 'production' }} + + - name: Comment on issues + uses: ./.github/actions/javascript/markPullRequestsAsDeployed + with: + PR_LIST: ${{ steps.getPullRequestList.outputs.PR_LIST }} + IS_PRODUCTION_DEPLOY: ${{ inputs.env == 'production' }} + DEPLOY_VERSION: ${{ inputs.version }} + GITHUB_TOKEN: ${{ github.token }} + ANDROID: ${{ inputs.android }} + DESKTOP: ${{ inputs.desktop }} + IOS: ${{ inputs.IOS }} + WEB: ${{ inputs.web }} + DATE: ${{ inputs.date }} From 555d3ec381a3083ff2333efb2d51f337723596d2 Mon Sep 17 00:00:00 2001 From: rory Date: Fri, 20 Sep 2024 17:18:22 -0700 Subject: [PATCH 2/8] Add support for additional note from deployer --- .../javascript/markPullRequestsAsDeployed/action.yml | 3 +++ .../markPullRequestsAsDeployed.ts | 6 ++++++ .github/workflows/postDeployComments.yml | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/actions/javascript/markPullRequestsAsDeployed/action.yml b/.github/actions/javascript/markPullRequestsAsDeployed/action.yml index 265dc07b3978..2b2e40314733 100644 --- a/.github/actions/javascript/markPullRequestsAsDeployed/action.yml +++ b/.github/actions/javascript/markPullRequestsAsDeployed/action.yml @@ -30,6 +30,9 @@ inputs: DATE: description: "The date of deployment" required: false + NOTE: + description: "Additional note from the deployer" + required: false runs: using: "node20" main: "./index.js" diff --git a/.github/actions/javascript/markPullRequestsAsDeployed/markPullRequestsAsDeployed.ts b/.github/actions/javascript/markPullRequestsAsDeployed/markPullRequestsAsDeployed.ts index 71a5c7d5c6ee..3d4d5f9f6227 100644 --- a/.github/actions/javascript/markPullRequestsAsDeployed/markPullRequestsAsDeployed.ts +++ b/.github/actions/javascript/markPullRequestsAsDeployed/markPullRequestsAsDeployed.ts @@ -55,6 +55,8 @@ async function run() { const iOSResult = getDeployTableMessage(core.getInput('IOS', {required: true}) as PlatformResult); const webResult = getDeployTableMessage(core.getInput('WEB', {required: true}) as PlatformResult); + const note = core.getInput('NOTE'); + function getDeployMessage(deployer: string, deployVerb: string, prTitle?: string): string { let message = `šŸš€ [${deployVerb}](${workflowURL}) to ${isProd ? 'production' : 'staging'}`; message += ` by https://github.com/${deployer} in version: ${version} šŸš€`; @@ -67,6 +69,10 @@ async function run() { '\n\n@Expensify/applauseleads please QA this PR and check it off on the [deploy checklist](https://github.com/Expensify/App/issues?q=is%3Aopen+is%3Aissue+label%3AStagingDeployCash) if it passes.'; } + if (note) { + message += `\n\n_Note:_ ${note}`; + } + return message; } diff --git a/.github/workflows/postDeployComments.yml b/.github/workflows/postDeployComments.yml index 144e03d7a043..8e0cb1f04c9e 100644 --- a/.github/workflows/postDeployComments.yml +++ b/.github/workflows/postDeployComments.yml @@ -88,7 +88,7 @@ on: description: The date when this deploy occurred required: false type: string - deployerNote: + note: description: Any additional note you want to include with the deploy comment required: false type: string @@ -123,3 +123,4 @@ jobs: IOS: ${{ inputs.IOS }} WEB: ${{ inputs.web }} DATE: ${{ inputs.date }} + NOTE: ${{ inputs.note }} From e7ce51dc6de956be38ff5d52d99b7a65f7955863 Mon Sep 17 00:00:00 2001 From: rory Date: Fri, 20 Sep 2024 17:24:49 -0700 Subject: [PATCH 3/8] use callable postDeployComments workflow in deploy.yml --- .github/workflows/deploy.yml | 38 ++++++------------------ .github/workflows/postDeployComments.yml | 8 ----- 2 files changed, 9 insertions(+), 37 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2ab19d13183a..53afe03720f7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -649,34 +649,14 @@ jobs: GITHUB_TOKEN: ${{ github.token }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} - postGithubComment: - name: Post a GitHub comments on all deployed PRs when platforms are done building and deploying - runs-on: ubuntu-latest + postGithubComments: + uses: ./.github/workflows/postDeployComments.yml if: ${{ always() && fromJSON(needs.checkDeploymentSuccess.outputs.IS_AT_LEAST_ONE_PLATFORM_DEPLOYED) }} needs: [prep, android, desktop, iOS, web, checkDeploymentSuccess, createPrerelease, finalizeRelease] - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Node - uses: ./.github/actions/composite/setupNode - - - name: Get Release Pull Request List - id: getReleasePRList - uses: ./.github/actions/javascript/getDeployPullRequestList - with: - TAG: ${{ needs.prep.outputs.APP_VERSION }} - GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} - IS_PRODUCTION_DEPLOY: ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} - - - name: Comment on issues - uses: ./.github/actions/javascript/markPullRequestsAsDeployed - with: - PR_LIST: ${{ steps.getReleasePRList.outputs.PR_LIST }} - IS_PRODUCTION_DEPLOY: ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} - DEPLOY_VERSION: ${{ needs.prep.outputs.APP_VERSION }} - GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} - ANDROID: ${{ needs.android.result }} - DESKTOP: ${{ needs.desktop.result }} - IOS: ${{ needs.iOS.result }} - WEB: ${{ needs.web.result }} + with: + version: ${{ needs.prep.outputs.APP_VERSION }} + env: ${{ github.ref == 'refs/heads/production' && 'production' || 'staging' }} + android: ${{ needs.android.result }} + ios: ${{ needs.iOS.result }} + web: ${{ needs.web.result }} + desktop: ${{ needs.desktop.result }} diff --git a/.github/workflows/postDeployComments.yml b/.github/workflows/postDeployComments.yml index 8e0cb1f04c9e..250794cc944b 100644 --- a/.github/workflows/postDeployComments.yml +++ b/.github/workflows/postDeployComments.yml @@ -11,10 +11,6 @@ on: description: The environment that was deployed (staging or prod) required: true type: string - isCP: - description: Was the deploy a CP? - required: true - type: boolean android: description: Android deploy status required: true @@ -44,10 +40,6 @@ on: options: - staging - production - isCP: - description: Was the deploy a CP? - required: true - type: boolean android: description: Android deploy status required: true From b63a80c46096e7a86233022fef137c9440d36975 Mon Sep 17 00:00:00 2001 From: rory Date: Fri, 20 Sep 2024 17:27:34 -0700 Subject: [PATCH 4/8] Rebuild gh actions --- .../actions/javascript/markPullRequestsAsDeployed/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/actions/javascript/markPullRequestsAsDeployed/index.js b/.github/actions/javascript/markPullRequestsAsDeployed/index.js index 9f97e4a72d20..692594e16aa4 100644 --- a/.github/actions/javascript/markPullRequestsAsDeployed/index.js +++ b/.github/actions/javascript/markPullRequestsAsDeployed/index.js @@ -12713,6 +12713,7 @@ async function run() { const desktopResult = getDeployTableMessage(core.getInput('DESKTOP', { required: true })); const iOSResult = getDeployTableMessage(core.getInput('IOS', { required: true })); const webResult = getDeployTableMessage(core.getInput('WEB', { required: true })); + const note = core.getInput('NOTE'); function getDeployMessage(deployer, deployVerb, prTitle) { let message = `šŸš€ [${deployVerb}](${workflowURL}) to ${isProd ? 'production' : 'staging'}`; message += ` by https://github.com/${deployer} in version: ${version} šŸš€`; @@ -12723,6 +12724,9 @@ async function run() { message += '\n\n@Expensify/applauseleads please QA this PR and check it off on the [deploy checklist](https://github.com/Expensify/App/issues?q=is%3Aopen+is%3Aissue+label%3AStagingDeployCash) if it passes.'; } + if (note) { + message += `\n\n_Note:_ ${note}`; + } return message; } if (isProd) { From 559f50666c138ff359ba782459bef5e67c8cc68a Mon Sep 17 00:00:00 2001 From: rory Date: Fri, 20 Sep 2024 17:30:39 -0700 Subject: [PATCH 5/8] Add support for custom date --- .../actions/javascript/markPullRequestsAsDeployed/index.js | 7 ++++++- .../markPullRequestsAsDeployed.ts | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/actions/javascript/markPullRequestsAsDeployed/index.js b/.github/actions/javascript/markPullRequestsAsDeployed/index.js index 692594e16aa4..b38b04141395 100644 --- a/.github/actions/javascript/markPullRequestsAsDeployed/index.js +++ b/.github/actions/javascript/markPullRequestsAsDeployed/index.js @@ -12713,10 +12713,15 @@ async function run() { const desktopResult = getDeployTableMessage(core.getInput('DESKTOP', { required: true })); const iOSResult = getDeployTableMessage(core.getInput('IOS', { required: true })); const webResult = getDeployTableMessage(core.getInput('WEB', { required: true })); + const date = core.getInput('DATE'); const note = core.getInput('NOTE'); function getDeployMessage(deployer, deployVerb, prTitle) { let message = `šŸš€ [${deployVerb}](${workflowURL}) to ${isProd ? 'production' : 'staging'}`; - message += ` by https://github.com/${deployer} in version: ${version} šŸš€`; + message += ` by https://github.com/${deployer} in version: ${version} `; + if (date) { + message += `on ${date}`; + } + message += `šŸš€`; message += `\n\nplatform | result\n---|---\nšŸ¤– android šŸ¤–|${androidResult}\nšŸ–„ desktop šŸ–„|${desktopResult}`; message += `\nšŸŽ iOS šŸŽ|${iOSResult}\nšŸ•ø web šŸ•ø|${webResult}`; if (deployVerb === 'Cherry-picked' && !/no ?qa/gi.test(prTitle ?? '')) { diff --git a/.github/actions/javascript/markPullRequestsAsDeployed/markPullRequestsAsDeployed.ts b/.github/actions/javascript/markPullRequestsAsDeployed/markPullRequestsAsDeployed.ts index 3d4d5f9f6227..e6424c89833a 100644 --- a/.github/actions/javascript/markPullRequestsAsDeployed/markPullRequestsAsDeployed.ts +++ b/.github/actions/javascript/markPullRequestsAsDeployed/markPullRequestsAsDeployed.ts @@ -55,11 +55,16 @@ async function run() { const iOSResult = getDeployTableMessage(core.getInput('IOS', {required: true}) as PlatformResult); const webResult = getDeployTableMessage(core.getInput('WEB', {required: true}) as PlatformResult); + const date = core.getInput('DATE'); const note = core.getInput('NOTE'); function getDeployMessage(deployer: string, deployVerb: string, prTitle?: string): string { let message = `šŸš€ [${deployVerb}](${workflowURL}) to ${isProd ? 'production' : 'staging'}`; - message += ` by https://github.com/${deployer} in version: ${version} šŸš€`; + message += ` by https://github.com/${deployer} in version: ${version} `; + if (date) { + message += `on ${date}`; + } + message += `šŸš€`; message += `\n\nplatform | result\n---|---\nšŸ¤– android šŸ¤–|${androidResult}\nšŸ–„ desktop šŸ–„|${desktopResult}`; message += `\nšŸŽ iOS šŸŽ|${iOSResult}\nšŸ•ø web šŸ•ø|${webResult}`; From 0a1cf583ed5f5d645c269a2f1e2f2ca6658537d4 Mon Sep 17 00:00:00 2001 From: rory Date: Fri, 20 Sep 2024 17:33:09 -0700 Subject: [PATCH 6/8] Make GITHUB_TOKEN required and remove default --- .../actions/javascript/markPullRequestsAsDeployed/action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/actions/javascript/markPullRequestsAsDeployed/action.yml b/.github/actions/javascript/markPullRequestsAsDeployed/action.yml index 2b2e40314733..40dfc05e5448 100644 --- a/.github/actions/javascript/markPullRequestsAsDeployed/action.yml +++ b/.github/actions/javascript/markPullRequestsAsDeployed/action.yml @@ -13,8 +13,7 @@ inputs: required: true GITHUB_TOKEN: description: "Github token for authentication" - required: false - default: "${{ github.token }}" + required: true ANDROID: description: "Android job result ('success', 'failure', 'cancelled', or 'skipped')" required: true From 0f495595860157cf30acf0542af9638fc0103948 Mon Sep 17 00:00:00 2001 From: rory Date: Fri, 20 Sep 2024 17:41:27 -0700 Subject: [PATCH 7/8] Fix tests --- tests/unit/markPullRequestsAsDeployedTest.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/unit/markPullRequestsAsDeployedTest.ts b/tests/unit/markPullRequestsAsDeployedTest.ts index 4d491db2e53e..45fa83a36734 100644 --- a/tests/unit/markPullRequestsAsDeployedTest.ts +++ b/tests/unit/markPullRequestsAsDeployedTest.ts @@ -84,6 +84,9 @@ function mockGetInputDefaultImplementation(key: string): boolean | string { case 'DESKTOP': case 'WEB': return 'success'; + case 'DATE': + case 'NOTE': + return ''; default: throw new Error('Trying to access invalid input'); } From 613f8930aaff808995732ac4e42809051d6fc751 Mon Sep 17 00:00:00 2001 From: Rory Abraham <47436092+roryabraham@users.noreply.github.com> Date: Sat, 21 Sep 2024 00:17:46 -0700 Subject: [PATCH 8/8] match case on ios inputs Co-authored-by: Vit Horacek <36083550+mountiny@users.noreply.github.com> --- .github/workflows/postDeployComments.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/postDeployComments.yml b/.github/workflows/postDeployComments.yml index 250794cc944b..3893d3cf3f7c 100644 --- a/.github/workflows/postDeployComments.yml +++ b/.github/workflows/postDeployComments.yml @@ -112,7 +112,7 @@ jobs: GITHUB_TOKEN: ${{ github.token }} ANDROID: ${{ inputs.android }} DESKTOP: ${{ inputs.desktop }} - IOS: ${{ inputs.IOS }} + IOS: ${{ inputs.ios }} WEB: ${{ inputs.web }} DATE: ${{ inputs.date }} NOTE: ${{ inputs.note }}