ci: use environments when deploying #716
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deployment | |
on: | |
pull_request: | |
push: | |
branches: | |
- master | |
- production | |
jobs: | |
check-dependencies: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Check dependencies for security vulnerabilities | |
uses: g-rath/check-with-osv-detector@main | |
tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- run: cp example.env .env | |
- name: Build the docker compose stack | |
run: docker compose up -d | |
- name: Check running containers | |
run: docker ps -a | |
- name: Check logs | |
run: docker compose logs backend | |
- name: Run test suite | |
run: docker compose run backend bin/runtests.py | |
deploy_to_uat: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
needs: | |
- check-dependencies | |
- tests | |
environment: | |
name: uat | |
url: https://signbank-uat.nzsl.nz | |
steps: | |
- uses: actions/checkout@v1 | |
- run: curl https://cli-assets.heroku.com/install-ubuntu.sh | sh | |
- run: cp example.env .env | |
- name: Build the docker compose stack | |
run: docker compose up -d | |
- name: Check running containers | |
run: docker ps -a | |
- name: Check logs | |
run: docker compose logs backend | |
- name: Deploy app to UAT | |
env: | |
HEROKU_API_KEY: ${{secrets.HEROKU_UAT_API_KEY}} | |
HEROKU_APP_NAME: ${{secrets.HEROKU_UAT_APP_NAME}} | |
run: | | |
echo $HEROKU_API_KEY | docker login --username=_ --password-stdin registry.heroku.com | |
docker tag $(docker compose images -q backend) registry.heroku.com/$HEROKU_APP_NAME/web | |
docker push registry.heroku.com/$HEROKU_APP_NAME/web | |
heroku container:release web -a $HEROKU_APP_NAME | |
deploy_to_production: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && github.ref == 'refs/heads/production' | |
needs: | |
- check-dependencies | |
- tests | |
environment: | |
name: production | |
url: https://signbank.nzsl.nz | |
steps: | |
- uses: actions/checkout@v1 | |
- run: curl https://cli-assets.heroku.com/install-ubuntu.sh | sh | |
- run: cp example.env .env | |
- name: Build the docker compose stack | |
run: docker compose up -d | |
- name: Check running containers | |
run: docker ps -a | |
- name: Check logs | |
run: docker compose logs backend | |
- name: Deploy app to Production | |
if: github.ref == 'refs/heads/production' | |
env: | |
HEROKU_API_KEY: ${{secrets.HEROKU_PRODUCTION_API_KEY}} | |
HEROKU_APP_NAME: ${{secrets.HEROKU_PRODUCTION_APP_NAME}} | |
run: | | |
echo $HEROKU_API_KEY | docker login --username=_ --password-stdin registry.heroku.com | |
docker tag $(docker compose images -q backend) registry.heroku.com/$HEROKU_APP_NAME/web | |
docker push registry.heroku.com/$HEROKU_APP_NAME/web | |
heroku container:release web -a $HEROKU_APP_NAME |