From 2b4f938e1b08653693456b92bc72b486baecb815 Mon Sep 17 00:00:00 2001 From: Rory Abraham Date: Fri, 3 Sep 2021 15:55:22 -0700 Subject: [PATCH] Swap out uses of string comparisons for fromJSON --- .github/workflows/cherryPick.yml | 12 ++++----- .github/workflows/deploy.yml | 4 +-- .github/workflows/finishReleaseCycle.yml | 10 ++++---- .github/workflows/platformDeploy.yml | 32 ++++++++++++------------ .github/workflows/preDeploy.yml | 8 +++--- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/.github/workflows/cherryPick.yml b/.github/workflows/cherryPick.yml index 59c267dc2b12..712d3304eb5a 100644 --- a/.github/workflows/cherryPick.yml +++ b/.github/workflows/cherryPick.yml @@ -27,7 +27,7 @@ jobs: createNewVersion: needs: validateActor runs-on: ubuntu-latest - if: ${{ needs.validateActor.outputs.IS_DEPLOYER == 'true' && github.event.inputs.NEW_VERSION == '' }} + if: ${{ fromJSON(needs.validateActor.outputs.IS_DEPLOYER) && github.event.inputs.NEW_VERSION == '' }} outputs: NEW_VERSION: ${{ steps.getNewVersion.outputs.NEW_VERSION }} steps: @@ -59,7 +59,7 @@ jobs: cherryPick: needs: [validateActor, createNewVersion] - if: ${{ always() && needs.validateActor.outputs.IS_DEPLOYER == 'true' }} + if: ${{ always() && fromJSON(needs.validateActor.outputs.IS_DEPLOYER) }} runs-on: ubuntu-latest steps: # Version: 2.3.4 @@ -144,7 +144,7 @@ jobs: PULL_REQUEST_NUMBER: ${{ steps.createPullRequest.outputs.pr_number }} - name: Auto-assign PR if there are merge conflicts - if: ${{ steps.cherryPick.outputs.SHOULD_AUTOMERGE == 'false' || steps.isPullRequestMergeable.outputs.IS_MERGEABLE == 'false' }} + if: ${{ !fromJSON(steps.cherryPick.outputs.SHOULD_AUTOMERGE) || !fromJSON(steps.isPullRequestMergeable.outputs.IS_MERGEABLE) }} uses: actions-ecosystem/action-add-labels@a8ae047fee0ca28235f9764e1c478d2136dc15c1 with: number: ${{ steps.createPullRequest.outputs.pr_number }} @@ -161,7 +161,7 @@ jobs: assignees: ${{ steps.getCPMergeCommit.outputs.MERGE_ACTOR }} - name: If PR has merge conflicts, comment with instructions for assignee - if: ${{ steps.cherryPick.outputs.SHOULD_AUTOMERGE == 'false' || steps.isPullRequestMergeable.outputs.IS_MERGEABLE == 'false' }} + if: ${{ !fromJSON(steps.cherryPick.outputs.SHOULD_AUTOMERGE) || !fromJSON(steps.isPullRequestMergeable.outputs.IS_MERGEABLE) }} uses: actions-ecosystem/action-create-comment@cd098164398331c50e7dfdd0dfa1b564a1873fac with: github_token: ${{ secrets.OS_BOTIFY_TOKEN }} @@ -173,7 +173,7 @@ jobs: - name: Check for an auto approve # Important: only auto-approve if there was no merge conflict! - if: ${{ steps.cherryPick.outputs.SHOULD_AUTOMERGE == 'true' && steps.isPullRequestMergeable.outputs.IS_MERGEABLE == 'true' }} + if: ${{ fromJSON(steps.cherryPick.outputs.SHOULD_AUTOMERGE) && fromJSON(steps.isPullRequestMergeable.outputs.IS_MERGEABLE) }} # Version: 2.0.0 uses: hmarr/auto-approve-action@6a9ec7556f0a7fa5b49527a1eea4878b8a22d2e0 with: @@ -182,7 +182,7 @@ jobs: - name: Check for an auto merge # Important: only auto-merge if there was no merge conflict! - if: ${{ steps.cherryPick.outputs.SHOULD_AUTOMERGE == 'true' && steps.isPullRequestMergeable.outputs.IS_MERGEABLE == 'true' }} + if: ${{ fromJSON(steps.cherryPick.outputs.SHOULD_AUTOMERGE) && fromJSON(steps.isPullRequestMergeable.outputs.IS_MERGEABLE) }} # Version: 0.12.0 uses: pascalgn/automerge-action@39d831e1bb389bd242626bc25d4060064a97181c env: diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5d68673888e0..60165609e7e8 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,7 +25,7 @@ jobs: deployStaging: runs-on: ubuntu-latest needs: validate - if: ${{ needs.validate.outputs.isAutomatedPullRequest == 'true' && github.ref == 'refs/heads/staging' }} + if: ${{ fromJSON(needs.validate.outputs.isAutomatedPullRequest) && github.ref == 'refs/heads/staging' }} steps: - name: Checkout staging branch @@ -43,7 +43,7 @@ jobs: deployProduction: runs-on: ubuntu-latest needs: validate - if: ${{ needs.validate.outputs.isAutomatedPullRequest == 'true' && github.ref == 'refs/heads/production' }} + if: ${{ fromJSON(needs.validate.outputs.isAutomatedPullRequest) && github.ref == 'refs/heads/production' }} steps: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f diff --git a/.github/workflows/finishReleaseCycle.yml b/.github/workflows/finishReleaseCycle.yml index c7bb77d23e8a..8ccce8375a23 100644 --- a/.github/workflows/finishReleaseCycle.yml +++ b/.github/workflows/finishReleaseCycle.yml @@ -23,7 +23,7 @@ jobs: team: mobile-deployers - name: Reopen and comment on issue - if: ${{ steps.validateActor.outputs.isTeamMember == 'false' }} + if: ${{ !fromJSON(steps.validateActor.outputs.isTeamMember) }} uses: Expensify/App/.github/actions/reopenIssueWithComment@main with: GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} @@ -33,7 +33,7 @@ jobs: Reopening! - name: Check for any deploy blockers - if: ${{ steps.validateActor.outputs.isTeamMember == 'true' }} + if: ${{ fromJSON(steps.validateActor.outputs.isTeamMember) }} id: checkDeployBlockers uses: Expensify/App/.github/actions/checkDeployBlockers@main with: @@ -41,7 +41,7 @@ jobs: ISSUE_NUMBER: ${{ github.event.issue.number }} - name: Reopen and comment on issue - if: ${{ steps.validateActor.outputs.isTeamMember == 'true' && steps.checkDeployBlockers.outputs.HAS_DEPLOY_BLOCKERS == 'true' }} + if: ${{ fromJSON(steps.validateActor.outputs.isTeamMember) && fromJSON(steps.checkDeployBlockers.outputs.HAS_DEPLOY_BLOCKERS) }} uses: Expensify/App/.github/actions/reopenIssueWithComment@main with: GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} @@ -54,7 +54,7 @@ jobs: updateProduction: runs-on: ubuntu-latest needs: validate - if: ${{ needs.validate.outputs.isValid == 'true' }} + if: ${{ fromJSON(needs.validate.outputs.isValid) }} steps: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f with: @@ -72,7 +72,7 @@ jobs: createNewStagingDeployCash: runs-on: macos-11 needs: validate - if: ${{ needs.validate.outputs.isValid == 'true' }} + if: ${{ fromJSON(needs.validate.outputs.isValid) }} steps: # Version: 2.3.4 - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f diff --git a/.github/workflows/platformDeploy.yml b/.github/workflows/platformDeploy.yml index 8d0771437af0..e80aac12ca63 100644 --- a/.github/workflows/platformDeploy.yml +++ b/.github/workflows/platformDeploy.yml @@ -80,11 +80,11 @@ jobs: run: echo "VERSION_CODE=$(grep -o 'versionCode\s\+[0-9]\+' android/app/build.gradle | awk '{ print $2 }')" >> $GITHUB_ENV - name: Run Fastlane beta - if: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'false' }} + if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} run: bundle exec fastlane android beta - name: Run Fastlane production - if: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'true' }} + if: ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} run: bundle exec fastlane android production env: VERSION: ${{ env.VERSION_CODE }} @@ -142,7 +142,7 @@ jobs: DEVELOPER_ID_SECRET_PASSPHRASE: ${{ secrets.DEVELOPER_ID_SECRET_PASSPHRASE }} - name: Build production desktop app - if: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'true' }} + if: ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} run: npm run desktop-build -- --publish always -c.afterSign=desktop/notarize.js env: CSC_LINK: ${{ secrets.CSC_LINK }} @@ -153,7 +153,7 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - name: Build staging desktop app - if: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'false' }} + if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} run: npm run desktop-build-staging -- --publish always -c.afterSign=desktop/notarize.js env: CSC_LINK: ${{ secrets.CSC_LINK }} @@ -233,7 +233,7 @@ jobs: LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} - name: Run Fastlane - if: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'false' }} + if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} run: bundle exec fastlane ios beta env: APPLE_CONTACT_EMAIL: ${{ secrets.APPLE_CONTACT_EMAIL }} @@ -246,7 +246,7 @@ jobs: run: echo "IOS_VERSION=$(echo '${{ github.event.release.tag_name }}' | tr '-' '.')" >> $GITHUB_ENV - name: Run Fastlane for App Store release - if: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'true' }} + if: ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} run: bundle exec fastlane ios production env: VERSION: ${{ env.IOS_VERSION }} @@ -317,32 +317,32 @@ jobs: command: npm ci - name: Build web for production - if: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'true' }} + if: ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} run: npm run build - name: Build web for staging - if: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'false' }} + if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} run: npm run build-staging - name: Build docs run: npm run storybook-build - name: Deploy production to S3 - if: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'true' }} + if: ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} run: aws s3 cp --recursive --acl public-read $GITHUB_WORKSPACE/dist s3://expensify-cash/ - name: Deploy staging to S3 - if: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'false' }} + if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} run: aws s3 cp --recursive --acl public-read $GITHUB_WORKSPACE/dist s3://staging-expensify-cash/ - name: Purge production Cloudflare cache - if: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'true' }} + if: ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} run: /home/runner/.local/bin/cli4 --delete hosts=["new.expensify.com"] /zones/:9ee042e6cfc7fd45e74aa7d2f78d617b/purge_cache env: CF_API_KEY: ${{ secrets.CLOUDFLARE_TOKEN }} - name: Purge staging Cloudflare cache - if: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'false' }} + if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} run: /home/runner/.local/bin/cli4 --delete hosts=["staging.new.expensify.com"] /zones/:9ee042e6cfc7fd45e74aa7d2f78d617b/purge_cache env: CF_API_KEY: ${{ secrets.CLOUDFLARE_TOKEN }} @@ -395,13 +395,13 @@ jobs: with: TAG: ${{ env.VERSION }} GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} - IS_PRODUCTION_DEPLOY: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'true' }} + IS_PRODUCTION_DEPLOY: ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} - name: Comment on issues uses: Expensify/App/.github/actions/markPullRequestsAsDeployed@main with: PR_LIST: ${{ steps.getReleasePRList.outputs.PR_LIST }} - IS_PRODUCTION_DEPLOY: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'true' }} + IS_PRODUCTION_DEPLOY: ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} DEPLOY_VERSION: ${{ env.VERSION }} GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} ANDROID: ${{ needs.android.result }} @@ -418,7 +418,7 @@ jobs: channel: '#announce', attachments: [{ color: 'good', - text: `🎉️ Successfully deployed ${process.env.AS_REPO} v${{ env.VERSION }} to ${{ env.SHOULD_DEPLOY_PRODUCTION == 'true' && 'production' || 'staging' }} 🎉️`, + text: `🎉️ Successfully deployed ${process.env.AS_REPO} v${{ env.VERSION }} to ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) && 'production' || 'staging' }} 🎉️`, }] } env: @@ -427,7 +427,7 @@ jobs: - name: 'Announces a production deploy in the #expensify-open-source Slack room' uses: 8398a7/action-slack@v3 - if: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'true' }} + if: ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} with: status: custom custom_payload: | diff --git a/.github/workflows/preDeploy.yml b/.github/workflows/preDeploy.yml index 75f89842cf9b..631854d7b4d3 100644 --- a/.github/workflows/preDeploy.yml +++ b/.github/workflows/preDeploy.yml @@ -43,7 +43,7 @@ jobs: skipDeploy: runs-on: ubuntu-latest needs: chooseDeployActions - if: ${{ needs.chooseDeployActions.outputs.isStagingDeployLocked == 'true' && needs.chooseDeployActions.outputs.isAutomatedPullRequest == 'false' && needs.chooseDeployActions.outputs.shouldCherryPick == 'false' }} + if: ${{ fromJSON(needs.chooseDeployActions.outputs.isStagingDeployLocked) && !fromJSON(needs.chooseDeployActions.outputs.isAutomatedPullRequest) && !fromJSON(needs.chooseDeployActions.outputs.shouldCherryPick) }} steps: - name: Comment on deferred PR @@ -57,7 +57,7 @@ jobs: version: runs-on: ubuntu-latest needs: chooseDeployActions - if: ${{ needs.chooseDeployActions.outputs.shouldCherryPick == 'true' || (needs.chooseDeployActions.outputs.isStagingDeployLocked == 'false' && needs.chooseDeployActions.outputs.isAutomatedPullRequest == 'false') }} + if: ${{ fromJSON(needs.chooseDeployActions.outputs.shouldCherryPick) || (!fromJSON(needs.chooseDeployActions.outputs.isStagingDeployLocked) && !fromJSON(needs.chooseDeployActions.outputs.isAutomatedPullRequest)) }} steps: # Version: 2.3.4 @@ -86,7 +86,7 @@ jobs: echo "New version is ${{ env.NEW_VERSION }}" - name: Update staging branch from main - if: ${{ needs.chooseDeployActions.outputs.isStagingDeployLocked == 'false' }} + if: ${{ !fromJSON(needs.chooseDeployActions.outputs.isStagingDeployLocked) }} uses: Expensify/App/.github/actions/triggerWorkflowAndWait@main with: GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} @@ -94,7 +94,7 @@ jobs: INPUTS: '{ "TARGET_BRANCH": "staging" }' - name: Cherry pick to staging - if: ${{ needs.chooseDeployActions.outputs.isStagingDeployLocked == 'true' && needs.chooseDeployActions.outputs.shouldCherryPick == 'true' }} + if: ${{ fromJSON(needs.chooseDeployActions.outputs.isStagingDeployLocked) && fromJSON(needs.chooseDeployActions.outputs.shouldCherryPick) }} uses: Expensify/App/.github/actions/triggerWorkflowAndWait@main with: GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}