Skip to content

Commit

Permalink
ficks conflicks
Browse files Browse the repository at this point in the history
  • Loading branch information
marcaaron committed Mar 17, 2021
2 parents 801809c + c5cb507 commit 4ab0d2b
Show file tree
Hide file tree
Showing 51 changed files with 772 additions and 547 deletions.
5 changes: 4 additions & 1 deletion .github/actions/isStagingDeployLocked/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ const run = function () {
const githubUtils = new GithubUtils(octokit);

return githubUtils.getStagingDeployCash()
.then(({labels}) => core.setOutput('IS_LOCKED', _.contains(_.pluck(labels, 'name'), '🔐 LockCashDeploys 🔐')))
.then(({labels}) => {
console.log(`Found StagingDeployCash with labels: ${_.pluck(labels, 'name')}`);
core.setOutput('IS_LOCKED', _.contains(_.pluck(labels, 'name'), '🔐 LockCashDeploys 🔐'));
})
.catch((err) => {
console.warn('No open StagingDeployCash found, continuing...', err);
core.setOutput('IS_LOCKED', false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ const run = function () {
const githubUtils = new GithubUtils(octokit);

return githubUtils.getStagingDeployCash()
.then(({labels}) => core.setOutput('IS_LOCKED', _.contains(_.pluck(labels, 'name'), '🔐 LockCashDeploys 🔐')))
.then(({labels}) => {
console.log(`Found StagingDeployCash with labels: ${_.pluck(labels, 'name')}`);
core.setOutput('IS_LOCKED', _.contains(_.pluck(labels, 'name'), '🔐 LockCashDeploys 🔐'));
})
.catch((err) => {
console.warn('No open StagingDeployCash found, continuing...', err);
core.setOutput('IS_LOCKED', false);
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/markPullRequestsAsDeployed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ const githubUtils = new GithubUtils(octokit);
prList.forEach((pr) => {
githubUtils.createComment(github.context.repo.repo, pr, message, octokit)
.then(() => {
console.log(`Comment created on #${pr} successfully`);
console.log(`Comment created on #${pr} successfully 🎉`);
})
.catch((err) => {
console.log(`Unable to write comment on #${pr}`);
console.log(`Unable to write comment on #${pr} 😞`);
core.setFailed(err.message);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ const githubUtils = new GithubUtils(octokit);
prList.forEach((pr) => {
githubUtils.createComment(github.context.repo.repo, pr, message, octokit)
.then(() => {
console.log(`Comment created on #${pr} successfully`);
console.log(`Comment created on #${pr} successfully 🎉`);
})
.catch((err) => {
console.log(`Unable to write comment on #${pr}`);
console.log(`Unable to write comment on #${pr} 😞`);
core.setFailed(err.message);
});
});
90 changes: 86 additions & 4 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ on:
status: {}

jobs:
automerge:
master:
runs-on: ubuntu-latest

if: github.event.pull_request.base.ref == 'master' && github.actor == 'OSBotify' && github.event.label.name == 'automerge'
steps:
- name: Export Files Changed
id: changed
Expand All @@ -24,14 +24,14 @@ 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
uses: pascalgn/automerge-action@c9bd1823770819dc8fb8a5db2d11a3a95fbe9b07
if: github.event.pull_request.mergeable && github.event.pull_request.mergeable_state == 'clean'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_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
Expand All @@ -53,3 +53,85 @@ jobs:
env:
GITHUB_TOKEN: ${{ github.token }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

staging:
runs-on: ubuntu-latest
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
uses: hmarr/auto-approve-action@7782c7e2bdf62b4d79bdcded8332808fd2f179cd
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
if: github.event.pull_request.mergeable && github.event.pull_request.head.ref == 'master'

- name: Check PR mergable states
run: echo "Mergeable - ${{ github.event.pull_request.mergeable }} Clean - ${{ github.event.pull_request.mergeable_state }}"

# TODO: make sure PR is in "clean" mergeable_state
- name: Check for an auto merge
# Version: 0.12.0
uses: pascalgn/automerge-action@c9bd1823770819dc8fb8a5db2d11a3a95fbe9b07
if: github.event.pull_request.mergeable
env:
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_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: `<!here>`,
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: 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
uses: hmarr/auto-approve-action@7782c7e2bdf62b4d79bdcded8332808fd2f179cd
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
if: github.event.pull_request.mergeable && github.event.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.OS_BOTIFY_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: `<!here>`,
text: `💥 ${process.env.AS_REPO} failed on ${process.env.AS_WORKFLOW} workflow 💥`,
}]
}
env:
GITHUB_TOKEN: ${{ github.token }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
6 changes: 5 additions & 1 deletion .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ jobs:
CLA:
runs-on: ubuntu-latest
# This job only runs for pull request comments or pull request target events (not issue comments)
if: github.event.issue.pull_request || github.event_name == 'pull_request_target'
# It does not run for pull requests created by OSBotify
# TODO: Fix this if so that it doesn't run CLA for pull requests created by OSBotify
if: ${{ github.event.issue.pull_request || (github.event_name == 'pull_request_target' && github.event.pull_request.user.login != 'OSBotify') }}
steps:
# TODO: remove this first run step
- run: echo ${{ github.event.pull_request.user.login }}
- uses: actions-ecosystem/action-regex-match@9c35fe9ac1840239939c59e5db8839422eed8a73
id: sign
with:
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Deploy code to staging or production

on:
push:
branches: [staging, production]

jobs:
validate:
runs-on: ubuntu-latest
outputs:
isAutomergePR: ${{ steps.isAutomergePR.outputs.IS_AUTOMERGE_PR }}

steps:
- name: Get merged pull request
id: getMergedPullRequest
uses: actions-ecosystem/action-get-merged-pull-request@59afe90821bb0b555082ce8ff1e36b03f91553d9
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Check if merged pull request was an automatic version bump PR
id: isAutomergePR
run: echo "::set-output name=IS_AUTOMERGE_PR::${{ contains(steps.getMergedPullRequest.outputs.labels, 'automerge') && github.actor == 'OSBotify' }}"

deployStaging:
runs-on: ubuntu-latest
needs: validate
if: ${{ needs.validate.outputs.isAutomergePR == 'true' && github.ref == 'refs/heads/staging' }}

steps:
- name: Checkout staging
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
with:
ref: staging
token: ${{ secrets.OS_BOTIFY_TOKEN }}

- name: Tag version
run: git tag $(npm run print-version --silent)

- name: 🚀 Push tags to trigger staging deploy 🚀
run: git push --tags

deployProduction:
runs-on: ubuntu-latest
needs: validate
if: ${{ needs.validate.outputs.isAutomergePR == 'true' && github.ref == 'refs/heads/production' }}

steps:
- name: Checkout production
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
with:
ref: production
token: ${{ secrets.OS_BOTIFY_TOKEN }}

- name: 🚀 Create release to trigger production deploy 🚀
run: echo "Create release with version $(npm run print-version --silent)"


1 change: 1 addition & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: E2E iOS Tests
on:
pull_request:
types: [opened, synchronize]
branches-ignore: [staging, production]

env:
DEVELOPER_DIR: /Applications/Xcode_12.3.app/Contents/Developer
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Lint JavaScript
on:
pull_request:
types: [opened, synchronize]
branches-ignore: [staging, production]

jobs:
lint:
Expand Down
45 changes: 38 additions & 7 deletions .github/workflows/preDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
outputs:
mergedPullRequest: ${{ steps.getMergedPullRequest.outputs.number }}
isStagingDeployLocked: ${{ steps.isStagingDeployLocked.outputs.IS_LOCKED }}
isVersionBumpPR: ${{ steps.isVersionBumpPR.outputs.IS_VERSION_BUMP_PR }}

steps:
# Version: 2.3.4
Expand All @@ -30,10 +31,14 @@ jobs:
with:
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}

- name: Check if merged pull request was an automatic version bump PR
id: isVersionBumpPR
run: echo "::set-output name=IS_VERSION_BUMP_PR::${{ contains(steps.getMergedPullRequest.outputs.labels, 'automerge') && github.actor == 'OSBotify' }}"

skipDeploy:
runs-on: ubuntu-latest
needs: chooseDeployActions
if: ${{ needs.chooseDeployActions.outputs.isStagingDeployLocked == 'true' }}
if: ${{ needs.chooseDeployActions.outputs.isStagingDeployLocked == 'true' && needs.chooseDeployActions.outputs.isVersionBumpPR == 'false' }}

steps:
- name: Comment on deferred PR
Expand All @@ -47,7 +52,9 @@ jobs:
version:
runs-on: macos-latest
needs: chooseDeployActions
if: ${{ needs.chooseDeployActions.outputs.isStagingDeployLocked == 'false' }}
if: ${{ needs.chooseDeployActions.outputs.isVersionBumpPR == 'false' }}
outputs:
newVersion: ${{ steps.bumpVersion.outputs.NEW_VERSION }}

steps:
# Version: 2.3.4
Expand Down Expand Up @@ -79,7 +86,7 @@ jobs:
with:
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}

- name: Commit and tag new version
- name: Commit new version
run: |
git add \
./package.json \
Expand All @@ -88,10 +95,6 @@ jobs:
./ios/ExpensifyCash/Info.plist \
./ios/ExpensifyCashTests/Info.plist
git commit -m "Update version to ${{ steps.bumpVersion.outputs.NEW_VERSION }}"
git tag ${{ steps.bumpVersion.outputs.NEW_VERSION }}
- name: Push tags
run: git push --tags
- name: Create Pull Request (master)
uses: peter-evans/create-pull-request@09b9ac155b0d5ad7d8d157ed32158c1b73689109
Expand Down Expand Up @@ -131,3 +134,31 @@ jobs:
env:
GITHUB_TOKEN: ${{ github.token }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

updateStaging:
runs-on: ubuntu-latest
needs: chooseDeployActions
if: ${{ needs.chooseDeployActions.outputs.isVersionBumpPR == 'true' && needs.chooseDeployActions.outputs.isStagingDeployLocked == 'false' }}

steps:
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
with:
fetch-depth: 0
token: ${{ secrets.OS_BOTIFY_TOKEN }}

- 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
with:
source_branch: master
destination_branch: staging
pr_label: automerge
github_token: ${{ secrets.OS_BOTIFY_TOKEN }}
pr_title: Update version to ${{ env.STAGING_VERSION }} on staging
pr_body: Update version to ${{ env.STAGING_VERSION }}
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Jest Unit Tests
on:
pull_request:
types: [opened, synchronize]
branches-ignore: [staging, production]

jobs:
test:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/verifyGithubActionBuilds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Verify Github Action Builds
on:
pull_request:
types: [opened, synchronize]
branches-ignore: [staging, production]

jobs:
verify:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/verifyPodfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Verify Podfile
on:
pull_request:
types: [opened, synchronize]
branches-ignore: [staging, production]

jobs:
verify:
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001000253
versionName "1.0.2-53"
versionCode 1001000268
versionName "1.0.2-68"
}
splits {
abi {
Expand Down
Loading

0 comments on commit 4ab0d2b

Please sign in to comment.