From 427572f8ba3b295f28731a5fe4ed8e0016f15b8c Mon Sep 17 00:00:00 2001 From: andrew Date: Tue, 16 Mar 2021 15:12:31 -0600 Subject: [PATCH 1/8] Set up two more jobs to handle staging and production cases --- .github/workflows/automerge.yml | 82 ++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 2 deletions(-) diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 7eac9e34cc87..1581e6d32f58 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -8,9 +8,9 @@ on: status: {} jobs: - automerge: + master: runs-on: ubuntu-latest - + if: pull_request.base.ref == 'master' steps: - name: Export Files Changed id: changed @@ -53,3 +53,81 @@ jobs: env: GITHUB_TOKEN: ${{ github.token }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + + staging: + runs-on: ubuntu-latest + if: pull_request.base.ref == 'staging' + steps: + - name: Check for an auto approve + # Version: 2.0.0 + uses: hmarr/auto-approve-action@7782c7e2bdf62b4d79bdcded8332808fd2f179cd + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + if: github.event.pull_request.mergeable && pull_request.head.ref == 'master' + + - name: Check for an auto merge + # Version: 0.12.0 + uses: pascalgn/automerge-action@c9bd1823770819dc8fb8a5db2d11a3a95fbe9b07 + if: github.event.pull_request.mergeable && github.event.pull_request.mergeable_state == 'clean' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # This Slack step is duplicated in all workflows, if you make a change to this step, make sure to update all + # the other workflows with the same change + - uses: 8398a7/action-slack@v3 + name: Job failed Slack notification + if: ${{ failure() }} + with: + status: custom + fields: workflow, repo + custom_payload: | + { + channel: '#announce', + attachments: [{ + color: "#DB4545", + pretext: ``, + text: `💥 ${process.env.AS_REPO} failed on ${process.env.AS_WORKFLOW} workflow 💥`, + }] + } + env: + GITHUB_TOKEN: ${{ github.token }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + + production: + runs-on: ubuntu-latest + if: pull_request.base.ref == 'production' + steps: + - name: Check for an auto approve + # Version: 2.0.0 + uses: hmarr/auto-approve-action@7782c7e2bdf62b4d79bdcded8332808fd2f179cd + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + if: github.event.pull_request.mergeable && pull_request.head.ref == 'staging' + + - name: Check for an auto merge + # Version: 0.12.0 + uses: pascalgn/automerge-action@c9bd1823770819dc8fb8a5db2d11a3a95fbe9b07 + if: github.event.pull_request.mergeable && github.event.pull_request.mergeable_state == 'clean' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # This Slack step is duplicated in all workflows, if you make a change to this step, make sure to update all + # the other workflows with the same change + - uses: 8398a7/action-slack@v3 + name: Job failed Slack notification + if: ${{ failure() }} + with: + status: custom + fields: workflow, repo + custom_payload: | + { + channel: '#announce', + attachments: [{ + color: "#DB4545", + pretext: ``, + text: `💥 ${process.env.AS_REPO} failed on ${process.env.AS_WORKFLOW} workflow 💥`, + }] + } + env: + GITHUB_TOKEN: ${{ github.token }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} From aeba3bf22d64690724926e92fd763fc1af35e8e1 Mon Sep 17 00:00:00 2001 From: andrew Date: Tue, 16 Mar 2021 15:15:13 -0600 Subject: [PATCH 2/8] Don't run PR tests on master, staging, or prod --- .github/workflows/cla.yml | 2 ++ .github/workflows/e2e.yml | 1 + .github/workflows/lint.yml | 1 + .github/workflows/test.yml | 1 + .github/workflows/verifyGithubActionBuilds.yml | 1 + .github/workflows/verifyPodfile.yml | 1 + 6 files changed, 7 insertions(+) diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index 1ab328213886..3967faa4faba 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -5,6 +5,8 @@ on: types: [created] pull_request_target: types: [opened, closed, synchronize] + pull_request: + branches-ignore: [master, staging, production] jobs: CLA: diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 1c0afae35981..1565fe4b5bc5 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -3,6 +3,7 @@ name: E2E iOS Tests on: pull_request: types: [opened, synchronize] + branches-ignore: [master, staging, production] env: DEVELOPER_DIR: /Applications/Xcode_12.3.app/Contents/Developer diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index bf0016694f7a..7212b4a15927 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,6 +3,7 @@ name: Lint JavaScript on: pull_request: types: [opened, synchronize] + branches-ignore: [master, staging, production] jobs: lint: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2f14b32ab963..8e87e62d09d3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,6 +3,7 @@ name: Jest Unit Tests on: pull_request: types: [opened, synchronize] + branches-ignore: [master, staging, production] jobs: test: diff --git a/.github/workflows/verifyGithubActionBuilds.yml b/.github/workflows/verifyGithubActionBuilds.yml index 70e2cb9e7dba..489c9462a22b 100644 --- a/.github/workflows/verifyGithubActionBuilds.yml +++ b/.github/workflows/verifyGithubActionBuilds.yml @@ -3,6 +3,7 @@ name: Verify Github Action Builds on: pull_request: types: [opened, synchronize] + branches-ignore: [master, staging, production] jobs: verify: diff --git a/.github/workflows/verifyPodfile.yml b/.github/workflows/verifyPodfile.yml index 9727d77f3849..5c3c8d01ad5a 100644 --- a/.github/workflows/verifyPodfile.yml +++ b/.github/workflows/verifyPodfile.yml @@ -3,6 +3,7 @@ name: Verify Podfile on: pull_request: types: [opened, synchronize] + branches-ignore: [master, staging, production] jobs: verify: From 60ca602c626e8a885914ee08007979dfbba76cbe Mon Sep 17 00:00:00 2001 From: andrew Date: Tue, 16 Mar 2021 15:17:05 -0600 Subject: [PATCH 3/8] Add github.event prefix --- .github/workflows/automerge.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 1581e6d32f58..37a91fd72421 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -10,7 +10,7 @@ on: jobs: master: runs-on: ubuntu-latest - if: pull_request.base.ref == 'master' + if: github.event.pull_request.base.ref == 'master' steps: - name: Export Files Changed id: changed @@ -56,7 +56,7 @@ jobs: staging: runs-on: ubuntu-latest - if: pull_request.base.ref == 'staging' + if: github.event.pull_request.base.ref == 'staging' steps: - name: Check for an auto approve # Version: 2.0.0 @@ -95,7 +95,7 @@ jobs: production: runs-on: ubuntu-latest - if: pull_request.base.ref == 'production' + if: github.event.pull_request.base.ref == 'production' steps: - name: Check for an auto approve # Version: 2.0.0 From 067c465554a4cc8fce2232a239e5cd3c26b91f0c Mon Sep 17 00:00:00 2001 From: andrew Date: Tue, 16 Mar 2021 15:18:27 -0600 Subject: [PATCH 4/8] Two more github.event. --- .github/workflows/automerge.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 37a91fd72421..84fdcfffcb8f 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -63,7 +63,7 @@ jobs: uses: hmarr/auto-approve-action@7782c7e2bdf62b4d79bdcded8332808fd2f179cd with: github-token: ${{ secrets.GITHUB_TOKEN }} - if: github.event.pull_request.mergeable && pull_request.head.ref == 'master' + if: github.event.pull_request.mergeable && github.event.pull_request.head.ref == 'master' - name: Check for an auto merge # Version: 0.12.0 @@ -102,7 +102,7 @@ jobs: uses: hmarr/auto-approve-action@7782c7e2bdf62b4d79bdcded8332808fd2f179cd with: github-token: ${{ secrets.GITHUB_TOKEN }} - if: github.event.pull_request.mergeable && pull_request.head.ref == 'staging' + if: github.event.pull_request.mergeable && github.event.pull_request.head.ref == 'staging' - name: Check for an auto merge # Version: 0.12.0 From 4754807735260cfc04c0a709f509620c6eb265aa Mon Sep 17 00:00:00 2001 From: andrew Date: Tue, 16 Mar 2021 15:25:18 -0600 Subject: [PATCH 5/8] Copy 05d3685 --- .github/workflows/automerge.yml | 8 ++++---- .github/workflows/preDeploy.yml | 8 ++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 84fdcfffcb8f..5c073e6a776c 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -10,7 +10,7 @@ on: jobs: master: runs-on: ubuntu-latest - if: github.event.pull_request.base.ref == 'master' + if: github.event.pull_request.base.ref == 'master' && github.actor == 'OSBotify' && github.event.label.name == 'automerge' steps: - name: Export Files Changed id: changed @@ -24,7 +24,7 @@ jobs: uses: hmarr/auto-approve-action@7782c7e2bdf62b4d79bdcded8332808fd2f179cd with: github-token: ${{ secrets.GITHUB_TOKEN }} - if: github.event.pull_request.mergeable && github.event.label.name == 'automerge' && github.actor == 'OSBotify' && steps.changed.outputs.files_updated == 'android/app/build.gradle ios/ExpensifyCash/Info.plist ios/ExpensifyCashTests/Info.plist package-lock.json package.json' && steps.changed.outputs.files_created == '' && steps.changed.outputs.files_deleted == '' + if: github.event.pull_request.mergeable && steps.changed.outputs.files_updated == 'android/app/build.gradle ios/ExpensifyCash/Info.plist ios/ExpensifyCashTests/Info.plist package-lock.json package.json' && steps.changed.outputs.files_created == '' && steps.changed.outputs.files_deleted == '' - name: Check for an auto merge # Version: 0.12.0 @@ -56,7 +56,7 @@ jobs: staging: runs-on: ubuntu-latest - if: github.event.pull_request.base.ref == 'staging' + if: github.event.pull_request.base.ref == 'staging' && github.actor == 'OSBotify' && github.event.label.name == 'automerge' steps: - name: Check for an auto approve # Version: 2.0.0 @@ -95,7 +95,7 @@ jobs: production: runs-on: ubuntu-latest - if: github.event.pull_request.base.ref == 'production' + if: github.event.pull_request.base.ref == 'production' && github.actor == 'OSBotify' && github.event.label.name == 'automerge' steps: - name: Check for an auto approve # Version: 2.0.0 diff --git a/.github/workflows/preDeploy.yml b/.github/workflows/preDeploy.yml index 2c453cb93b25..eda34107b2cc 100644 --- a/.github/workflows/preDeploy.yml +++ b/.github/workflows/preDeploy.yml @@ -38,9 +38,7 @@ jobs: skipDeploy: runs-on: ubuntu-latest needs: chooseDeployActions - if: | - ${{ needs.chooseDeployActions.outputs.isStagingDeployLocked == 'true' }} && - ${{ needs.chooseDeployActions.outputs.isVersionBumpPR == 'false' }} + if: ${{ needs.chooseDeployActions.outputs.isStagingDeployLocked == 'true' }} && ${{ needs.chooseDeployActions.outputs.isVersionBumpPR == 'false' }} steps: - name: Comment on deferred PR @@ -140,9 +138,7 @@ jobs: updateStaging: runs-on: ubuntu-latest needs: chooseDeployActions - if: | - ${{ needs.chooseDeployActions.outputs.isVersionBumpPR == 'true' }} && - ${{ needs.chooseDeployActions.outputs.isStagingDeployLocked == 'false' }} + if: ${{ needs.chooseDeployActions.outputs.isVersionBumpPR == 'true' }} && ${{ needs.chooseDeployActions.outputs.isStagingDeployLocked == 'false' }} steps: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f From 18dc66e0b30680760b1dd3372213a61a1f7bfea6 Mon Sep 17 00:00:00 2001 From: andrew Date: Tue, 16 Mar 2021 15:33:34 -0600 Subject: [PATCH 6/8] Set staging version to fix bug --- .github/workflows/preDeploy.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/preDeploy.yml b/.github/workflows/preDeploy.yml index eda34107b2cc..6ff4c2eb81db 100644 --- a/.github/workflows/preDeploy.yml +++ b/.github/workflows/preDeploy.yml @@ -149,6 +149,10 @@ jobs: - name: Checkout master branch run: git checkout master + - name: Set Staging Version + run: | + echo "STAGING_VERSION=$(npm run print-version --silent)" >> $GITHUB_ENV + - name: Create Pull Request # Version: 2.4.3 uses: repo-sync/pull-request@33777245b1aace1a58c87a29c90321aa7a74bd7d @@ -157,5 +161,5 @@ jobs: destination_branch: staging pr_label: automerge github_token: ${{ secrets.OS_BOTIFY_TOKEN }} - pr_title: Update version to $(npm run print-version --silent) on staging - pr_body: Update version to $(npm run print-version --silent) + pr_title: Update version to ${{ env.STAGING_VERSION }} on staging + pr_body: Update version to ${{ env.STAGING_VERSION }} From 2421e524e0b475647413867c7a486bce3017b124 Mon Sep 17 00:00:00 2001 From: andrew Date: Tue, 16 Mar 2021 15:55:02 -0600 Subject: [PATCH 7/8] Skip version commits with message and run actions on master --- .github/workflows/cla.yml | 2 +- .github/workflows/e2e.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/preDeploy.yml | 2 +- .github/workflows/test.yml | 2 +- .github/workflows/verifyGithubActionBuilds.yml | 2 +- .github/workflows/verifyPodfile.yml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index 3967faa4faba..70f1f8dd2929 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -6,7 +6,7 @@ on: pull_request_target: types: [opened, closed, synchronize] pull_request: - branches-ignore: [master, staging, production] + branches-ignore: [staging, production] jobs: CLA: diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 1565fe4b5bc5..523b17acac0f 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -3,7 +3,7 @@ name: E2E iOS Tests on: pull_request: types: [opened, synchronize] - branches-ignore: [master, staging, production] + branches-ignore: [staging, production] env: DEVELOPER_DIR: /Applications/Xcode_12.3.app/Contents/Developer diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7212b4a15927..9fee19b8a69c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,7 +3,7 @@ name: Lint JavaScript on: pull_request: types: [opened, synchronize] - branches-ignore: [master, staging, production] + branches-ignore: [staging, production] jobs: lint: diff --git a/.github/workflows/preDeploy.yml b/.github/workflows/preDeploy.yml index 6ff4c2eb81db..9adc362f422e 100644 --- a/.github/workflows/preDeploy.yml +++ b/.github/workflows/preDeploy.yml @@ -94,7 +94,7 @@ jobs: ./android/app/build.gradle \ ./ios/ExpensifyCash/Info.plist \ ./ios/ExpensifyCashTests/Info.plist - git commit -m "Update version to ${{ steps.bumpVersion.outputs.NEW_VERSION }}" + git commit -m "[skip actions] Update version to ${{ steps.bumpVersion.outputs.NEW_VERSION }}" - name: Create Pull Request (master) uses: peter-evans/create-pull-request@09b9ac155b0d5ad7d8d157ed32158c1b73689109 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8e87e62d09d3..7addc4e18c98 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ name: Jest Unit Tests on: pull_request: types: [opened, synchronize] - branches-ignore: [master, staging, production] + branches-ignore: [staging, production] jobs: test: diff --git a/.github/workflows/verifyGithubActionBuilds.yml b/.github/workflows/verifyGithubActionBuilds.yml index 489c9462a22b..21fa3213259b 100644 --- a/.github/workflows/verifyGithubActionBuilds.yml +++ b/.github/workflows/verifyGithubActionBuilds.yml @@ -3,7 +3,7 @@ name: Verify Github Action Builds on: pull_request: types: [opened, synchronize] - branches-ignore: [master, staging, production] + branches-ignore: [staging, production] jobs: verify: diff --git a/.github/workflows/verifyPodfile.yml b/.github/workflows/verifyPodfile.yml index 5c3c8d01ad5a..2cb062700dd9 100644 --- a/.github/workflows/verifyPodfile.yml +++ b/.github/workflows/verifyPodfile.yml @@ -3,7 +3,7 @@ name: Verify Podfile on: pull_request: types: [opened, synchronize] - branches-ignore: [master, staging, production] + branches-ignore: [staging, production] jobs: verify: From 0647c363f64e1f01250625373e2b2805d31d1a53 Mon Sep 17 00:00:00 2001 From: andrew Date: Tue, 16 Mar 2021 16:13:55 -0600 Subject: [PATCH 8/8] Apply peer review comments --- .github/workflows/preDeploy.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/preDeploy.yml b/.github/workflows/preDeploy.yml index 9adc362f422e..1cd37ed380b2 100644 --- a/.github/workflows/preDeploy.yml +++ b/.github/workflows/preDeploy.yml @@ -38,7 +38,7 @@ jobs: skipDeploy: runs-on: ubuntu-latest needs: chooseDeployActions - if: ${{ needs.chooseDeployActions.outputs.isStagingDeployLocked == 'true' }} && ${{ needs.chooseDeployActions.outputs.isVersionBumpPR == 'false' }} + if: ${{ needs.chooseDeployActions.outputs.isStagingDeployLocked == 'true' && needs.chooseDeployActions.outputs.isVersionBumpPR == 'false' }} steps: - name: Comment on deferred PR @@ -138,7 +138,7 @@ jobs: updateStaging: runs-on: ubuntu-latest needs: chooseDeployActions - if: ${{ needs.chooseDeployActions.outputs.isVersionBumpPR == 'true' }} && ${{ needs.chooseDeployActions.outputs.isStagingDeployLocked == 'false' }} + if: ${{ needs.chooseDeployActions.outputs.isVersionBumpPR == 'true' && needs.chooseDeployActions.outputs.isStagingDeployLocked == 'false' }} steps: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f @@ -150,8 +150,7 @@ jobs: run: git checkout master - name: Set Staging Version - run: | - echo "STAGING_VERSION=$(npm run print-version --silent)" >> $GITHUB_ENV + run: echo "STAGING_VERSION=$(npm run print-version --silent)" >> $GITHUB_ENV - name: Create Pull Request # Version: 2.4.3