Skip to content

Commit

Permalink
Merge pull request #5078 from Expensify/Rory-RefactorFromJSON
Browse files Browse the repository at this point in the history
[No QA] Swap out uses of string comparisons for fromJSON
  • Loading branch information
Gonals authored Sep 6, 2021
2 parents 51003eb + 2b4f938 commit b3421ce
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/cherryPick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand All @@ -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:
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/finishReleaseCycle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -33,15 +33,15 @@ 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:
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}
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 }}
Expand All @@ -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:
Expand All @@ -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
Expand Down
32 changes: 16 additions & 16 deletions .github/workflows/platformDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand All @@ -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:
Expand All @@ -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: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/preDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -86,15 +86,15 @@ 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 }}
WORKFLOW: updateProtectedBranch.yml
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 }}
Expand Down

0 comments on commit b3421ce

Please sign in to comment.