Heroku #13
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: Heroku | |
# Based on https://janjones.me/posts/github-action-heroku-deployment/ | |
on: deployment_status | |
jobs: | |
deployment-status: | |
name: Check deployment status | |
runs-on: ubuntu-latest | |
# Continue only if some definitive status has been reported. | |
if: github.event.deployment_status.state != 'pending' | |
steps: | |
# Forward deployment's status to the deployed commit. | |
- uses: octokit/request-action@v2.x | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
route: POST /repos/:repository/statuses/${{ github.event.deployment.sha }} | |
repository: ${{ github.repository }} | |
state: ${{ github.event.deployment_status.state }} | |
target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
description: > | |
${{ format('Heroku deployment is {0}', github.event.deployment_status.state) }} | |
context: Heroku / Deployment status | |
health-check: | |
name: Check site health | |
runs-on: ubuntu-latest | |
# Run health check only if deployment succeeds. | |
if: github.event.deployment_status.state == 'success' | |
# Check that the deployed app returns successful HTTP response. | |
steps: | |
- id: health_check | |
uses: jtalk/url-health-check-action@v3.2 | |
with: | |
url: ${{ github.event.deployment.payload.web_url }} | |
follow-redirect: true | |
max-attempts: 4 | |
retry-delay: 30s | |
continue-on-error: true | |
# Set appropriate status to the deployed commit. | |
- uses: octokit/request-action@v2.x | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
route: POST /repos/:repository/statuses/${{ github.event.deployment.sha }} | |
repository: ${{ github.repository }} | |
state: ${{ steps.health_check.outcome }} | |
target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
description: > | |
${{ format('Site health is {0}', steps.health_check.outcome) }} | |
context: Heroku / Site health |