Skip to content
Open
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
33 changes: 33 additions & 0 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Run Tests
on:
push:
paths-ignore:
- 'README.md'
pull_request:
types: [opened, reopened]
jobs:
Expand All @@ -24,3 +27,33 @@ jobs:
--env BOARD_KEY=${{ secrets.BOARD_KEY }}
todo-app:test
tests/e2e/test_chromium.py

deploy:
name: Deploy into production
needs: run-tests
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
runs-on: ubuntu-latest
env:
HEROKU_API_KEY: "${{ secrets.HEROKU_API_KEY }}"
DOCKER_USERNAME: "${{ secrets.DOCKER_USERNAME }}"
DOCKER_PASSWORD: "${{ secrets.DOCKER_PASSWORD }}"
steps:
- uses: actions/checkout@v1
- name: Login to Docker Hub
run: echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin
- name: Build production docker image
run: docker build --target production --tag $DOCKER_USERNAME/todo-app-production:${GITHUB_SHA::6} --tag $DOCKER_USERNAME/todo-app-production:latest .
- name: Push commit hash tagged build to Docker Hub
run: docker push $DOCKER_USERNAME/todo-app-production:${GITHUB_SHA::6}
- name: Push latest tagged build to Docker Hub
run: docker push $DOCKER_USERNAME/todo-app-production:latest
Comment on lines +46 to +49

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor, but you can combine these by asking docker to use the --all-tags flag so that it pushes both of these at once:

Suggested change
- name: Push commit hash tagged build to Docker Hub
run: docker push $DOCKER_USERNAME/todo-app-production:${GITHUB_SHA::6}
- name: Push latest tagged build to Docker Hub
run: docker push $DOCKER_USERNAME/todo-app-production:latest
- name: Push tagged builds to Docker Hub
run: docker push $DOCKER_USERNAME/todo-app-production:${GITHUB_SHA::6} --all-tags

- name: Pull production image from Docker Hub
run: docker pull $DOCKER_USERNAME/todo-app-production:latest
Comment on lines +50 to +51

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No real point pulling the image here - even if someone had changed it between the last step and this one, it's not obvious to me that we'd want to release their version of the image

- name: Tag production image on Heroku
run: docker tag $DOCKER_USERNAME/todo-app-production:latest registry.heroku.com/$DOCKER_USERNAME-todo/web
- name: Login to Heroku registry
run: echo $HEROKU_API_KEY | docker login --username=_ --password-stdin registry.heroku.com
- name: Push production image to Heroku registry
run: docker push registry.heroku.com/$DOCKER_USERNAME-todo/web
- name: Release the container on the Heroku registry
run: HEROKU_API_KEY=$HEROKU_API_KEY heroku container:release -a $DOCKER_USERNAME-todo web