Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up two more jobs to handle staging and production cases for automerge workflow #1802

Merged
merged 8 commits into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 81 additions & 3 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,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
Expand Down Expand Up @@ -53,3 +53,81 @@ 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 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: `<!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.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: `<!here>`,
text: `💥 ${process.env.AS_REPO} failed on ${process.env.AS_WORKFLOW} workflow 💥`,
}]
}
env:
GITHUB_TOKEN: ${{ github.token }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
2 changes: 2 additions & 0 deletions .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
types: [created]
pull_request_target:
types: [opened, closed, synchronize]
pull_request:
branches-ignore: [staging, production]

jobs:
CLA:
Expand Down
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
17 changes: 8 additions & 9 deletions .github/workflows/preDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -96,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
Expand Down Expand Up @@ -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
Expand All @@ -153,6 +149,9 @@ 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
Expand All @@ -161,5 +160,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 }}
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