Skip to content

Commit

Permalink
chore: deploy to 'alpha' only if the unit test workflow succeeds
Browse files Browse the repository at this point in the history
Right now, the "unit test" workflow and the "deploy to alpha" workflow
run in parallel.

This means that the code will get deployed to alpha, even if it doesn't
pass the tests, which is kinda dangerous (on the other hand, it's
alpha so we might not care).

This change links the two workflows together, so that "deploy to alpha"
only runs if the unit tests on master ran successfully.

Feel free to take or close this if you don't care about this!

Two additional notes:

* The tests also run on the PR build, but that's pre-merge and it's not
  necessarily guaranteed that the tests will pass after the merge.
* This has no impact on the "deploy to prod" workflow; it's still
  very well possible to deploy a `master` to production that doesn't
  pass tests. We need to write the workflows slightly differently if
  we also want to protect against that.
  • Loading branch information
rix0rrr committed Mar 31, 2021
1 parent 0a6b05a commit a17e42c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/deploy-to-alpha.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
name: Automatically deploy to Alpha
on:
push:
# Run this AFTER the unit test job finishes
workflow_run:
# Must be the same as in unittests.yml
workflows: ["Unit tests"]
branches: [master]
types:
- completed
jobs:
deploy:
# Deploy ONLY IF the tests actually succeeded (if they failed, we don't wanna deploy)
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application
# If you change this name, don't forget to change deploy-to-alpha.yml
name: Unit tests

on:
push:
Expand Down

0 comments on commit a17e42c

Please sign in to comment.