GitHub Action that associates a workflow run with a ShipAtlas Hub deployment.
When a deployment is created on Hub, it creates a GitHub deployment which then dispatches a deployment
event. Hub then relies on workflows configured to trigger workflow runs on: deployment
. The progress of the created workflow runs (from the deployment
trigger) are tracked by listening their workflow_run
events. Unfortunately the deployment
event doesn't provide any way to identify the workflow run running the deployment so that Hub can programmatically track it.
Which is where this action comes in. It takes advantage of the fact that the workflow run has access to the deployment
event that triggered it in github
context. With the information therein, it's possible to communicate back to Hub which of its deployments is responsible for the workflow run.
Set up the deploy job to have the association job as a pre-requisite as shown below:
name: deploy-application
on:
- deployment
jobs:
associate:
runs-on: ubuntu-latest
steps:
- name: Associate Deployment
uses: shipatlas/hub-deployment-associator@v1
deploy:
runs-on: ubuntu-latest
needs: associate
steps:
- name: Checkout
uses: actions/checkout@v3
# [... continuation of deployment process ...]
If the association succeeds, the deploy will proceed. And if it fails, the deploy won't run.