Resumen
You can use the jobs.<job_id>.if conditional to prevent a job from running unless a condition is met. Puedes usar cualquier contexto y expresión admitidos para crear un condicional.
Podrías omitir la sintaxis de expresión cuando utilizas expresiones en un condicional if (${{ }}) ya que GitHub evalúa automáticamente el condicional if como una expresión. Para obtener más información, consulta la sección "Expresiones".
Example: Only run job for specific repository
This example uses if to control when the production-deploy job can run. It will only run if the repository is named octo-repo-prod and is within the octo-org organization. Otherwise, the job will be marked as skipped.
name: example-workflow
on: [push]
jobs:
production-deploy:
if: github.repository == 'octo-org/octo-repo-prod'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- run: npm install -g bats