Skip to content

Deploy

Deploy #70

Workflow file for this run

name: Deploy
on:
workflow_run:
workflows:
- Test
branches:
- main
- develop
types:
- completed
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
env:
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
DOCKER_USERNAME: ${{ github.repository_owner }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
DOCKER_IMAGE: ${{ github.repository }}
jobs:
deploy:
name: Deploy application to Heroku
runs-on: ubuntu-latest
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.workflow_run.head_branch || github.ref }}
- name: Set BRANCH_TAG
uses: nimblehq/branch-tag-action@v1
with:
ref: ${{ github.event.workflow_run.head_branch || github.ref }}
- name: Set HEROKU_APP
run: |
if [[ $BRANCH_TAG = "latest" ]]
then
echo "HEROKU_APP=nimble-survey-web" >> $GITHUB_ENV
else
echo "HEROKU_APP=nimble-survey-web-staging" >> $GITHUB_ENV
fi
- name: Log in to Docker registry
run: echo "$DOCKER_TOKEN" | docker login $DOCKER_REGISTRY --username=$DOCKER_USERNAME --password-stdin
- name: Build Docker image
run: |
bin/docker-prepare
docker-compose build
docker-compose push web
- name: Log in to Heroku container
run: heroku container:login
- name: Publish application
run: |
heroku container:push --arg DOCKER_REGISTRY=$DOCKER_REGISTRY,DOCKER_IMAGE=$DOCKER_IMAGE,BRANCH_TAG=$BRANCH_TAG --recursive
heroku container:release web worker