Manual Job execution

Hello

I have a workflow and build, test, lint, and deploy jobs.

build, test, lint jobs are executed on push or pull.
but the deploy job should be executed manually.

currently, I’m using the ‘if’ statement for manual deploy but this executes all other jobs again.
I don’t want to redundant test for just the deployment.

How can I just execute only the deploy job when I want?

If I use a separate workflow, how can I know all test jobs succeed before deploy?

deploy:
# this workflow executed when manual execution
if: github.event_name == ‘workflow_dispatch’

needs: [test, lint]

The easiest solution to this might be to create an environment that requires manual approval for the workflow run, and then set that environment just for the deploy job: jobs.<job_id>.environment

Jobs that reference an environment configured with required reviewers will wait for an approval before starting. While a job is awaiting approval, it has a status of “Waiting”. If a job is not approved within 30 days, the workflow run will be automatically canceled.

https://docs.github.com/en/actions/managing-workflow-runs/reviewing-deployments

1 Like