Use ENV APP_DOMAIN instead of specific host #103
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: Deploy | |
on: | |
workflow_run: | |
workflows: | |
- Test | |
branches: | |
- main | |
- develop | |
types: | |
- completed | |
workflow_dispatch: | |
push: | |
branches: | |
- poc/docker-multi-stages | |
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@v4 | |
with: | |
ref: ${{ github.event.workflow_run.head_branch || github.ref }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Set BRANCH_TAG | |
uses: nimblehq/branch-tag-action@v1 | |
with: | |
ref: ${{ github.event.workflow_run.head_branch || github.ref }} | |
- name: Set HEROKU_APP env variable | |
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: Set DOCKER_IMAGE_TAG env variable | |
run: | | |
echo "DOCKER_IMAGE_TAG=$DOCKER_REGISTRY/$DOCKER_IMAGE:$BRANCH_TAG" >> $GITHUB_ENV | |
echo "MAKE UP DOCKER IMAGE TAG" | |
echo $DOCKER_IMAGE_TAG | |
- name: Prepare Docker image | |
run: | | |
bin/docker-prepare | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY }} | |
username: ${{ env.DOCKER_USERNAME }} | |
password: ${{ env.DOCKER_TOKEN }} | |
- name: Docker build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ env.DOCKER_IMAGE_TAG }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- 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 |