Skip to content

Commit

Permalink
Deploy to staging first & then production
Browse files Browse the repository at this point in the history
  • Loading branch information
vivekweb2013 committed May 26, 2022
1 parent d2a8dc8 commit e3d6b91
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ on:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
HEROKU_APP_NAME: batnoter
HEROKU_STAGING_APP_NAME: batnoter-staging
HEROKU_PRODUCTION_APP_NAME: batnoter

jobs:

Expand All @@ -23,7 +28,8 @@ jobs:
HEROKU_PROCESS_TYPE: web
run: |
docker build \
-t registry.heroku.com/$HEROKU_APP_NAME/$HEROKU_PROCESS_TYPE \
-t registry.heroku.com/$HEROKU_STAGING_APP_NAME/$HEROKU_PROCESS_TYPE \
-t registry.heroku.com/$HEROKU_PRODUCTION_APP_NAME/$HEROKU_PROCESS_TYPE \
-t $GITHUB_REPO_REGISTRY/${GITHUB_REPOSITORY#*/}:${GITHUB_REF##*/} \
-t $GITHUB_REPO_REGISTRY/${GITHUB_REPOSITORY#*/}:$COMMIT_SHA \
-t $GITHUB_REPO_REGISTRY/${GITHUB_REPOSITORY#*/}:latest .
Expand All @@ -50,20 +56,37 @@ jobs:
env:
HEROKU_PROCESS_TYPE: web
run: |
docker push -a registry.heroku.com/$HEROKU_APP_NAME/$HEROKU_PROCESS_TYPE
docker push -a registry.heroku.com/$HEROKU_STAGING_APP_NAME/$HEROKU_PROCESS_TYPE
docker push -a registry.heroku.com/$HEROKU_PRODUCTION_APP_NAME/$HEROKU_PROCESS_TYPE
deploy:
deploy-staging:
needs: [build]
runs-on: ubuntu-latest

environment:
name: Staging
url: 'https://batnoter-staging.herokuapp.com/'

steps:
- name: publish to staging on heroku
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
run: |
heroku container:release web -a $HEROKU_STAGING_APP_NAME
heroku releases --json -n 1 -a $HEROKU_STAGING_APP_NAME | grep '"succeeded"'
deploy-production:
needs: [deploy-staging]
runs-on: ubuntu-latest

environment:
name: Production
url: 'https://batnoter.com'
url: 'https://batnoter.herokuapp.com/'

steps:
- name: publish release on heroku
- name: publish to production on heroku
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
run: |
heroku container:release web -a $HEROKU_APP_NAME
heroku releases --json -n 1 -a $HEROKU_APP_NAME | grep '"succeeded"'
heroku container:release web -a $HEROKU_PRODUCTION_APP_NAME
heroku releases --json -n 1 -a $HEROKU_PRODUCTION_APP_NAME | grep '"succeeded"'

0 comments on commit e3d6b91

Please sign in to comment.