Conditional Deployment
The default out-of-the-box deployment.yml
will deploy every time you push to one of the three branches configured in the push
section:
You can customize this based on your needs. For example, you may have a CI workflow that runs tests and you only want to deploy when the tests pass. You can do this by configuring the on
section to your deployment.yml
file.
Adding condition
In your jobs
section you will also need to add an if
Swapping out References
Given that the deployment will now be triggered by another workflow instead of a push, the action will not have access to the correct ref
and sha
. We need to reference the ref
and sha
from the workflow that triggered the deployment
.
You will also need to replace the following values:
- From
${{ github.ref }}
to${{ github.event.workflow_run.head_branch }}
. - From
${{ github.sha }}
to${{ github.event.workflow_run.head_sha }}
.