-
-
Save swanson/527e20ea124c6896e9a0ca20a60c0d3e to your computer and use it in GitHub Desktop.
name: Deploy | |
on: | |
workflow_run: | |
workflows: [CI Build] # change this to match your build workflow name | |
types: [completed] | |
branches: [main] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
environment: | |
name: your-environment-name-here | |
url: https://your-app.example.com | |
name: Deploy demo | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Push to Heroku | |
run: git push -f https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git main | |
env: | |
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} | |
HEROKU_APP_NAME: your-heroku-app |
If you're just using
git push
(and not interacting with Heroku in any other way), you can get away without the CLI entirely:git push -f https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git main
Awesome, thank you. Switching over and then will update. Much simpler!
Just noticed I did sneak a force flag (-f
) into the push command which you may not want. It made sense for my use case, but I guess it's safer without!
Just noticed I did sneak a force flag (
-f
) into the push command which you may not want. It made sense for my use case, but I guess it's safer without!
I think it's appropriate as sometimes people manually deploy different branches.
Just noticed I did sneak a force flag (
-f
) into the push command which you may not want. It made sense for my use case, but I guess it's safer without!I think it's appropriate as sometimes people manually deploy different branches.
Makes sense. You may want to add a concurrency key, in case you merge a couple PRs in quick succession and their CI workflows complete out of order.
Edit: Actually I'm not even sure that'd keep you safe. Here be dragons -f
.
You may want to add a concurrency key, in case you merge a couple PRs in quick succession and their CI workflows complete out of order.
Yes. Very important addition
I think it's the presence of
environment
You are right.
If you're just using
git push
(and not interacting with Heroku in any other way), you can get away without the CLI entirely: