-
Notifications
You must be signed in to change notification settings - Fork 1
Sequential Workflows Simple Example
olsido edited this page Aug 5, 2024
·
1 revision
Sequential workflows ensure that one workflow runs only after another has completed. This is useful for workflows that depend on the successful completion of previous tasks, such as deploying an application after running tests.
name: First Workflow # Name of the workflow
on:
workflow_dispatch: # This workflow can be manually triggered
jobs:
first-workflow-job: # Job to run in this workflow
runs-on: ubuntu-latest # Use the latest Ubuntu runner
steps:
- name: First Workflow Only Step # Step to run in this job
run: echo "This is the first workflow" # Command to runView on Gist View in this repo
name: Second Workflow # Name of the workflow
on:
workflow_run: # This workflow is triggered by the completion of another workflow
workflows: ["First Workflow"] # The workflow that triggers this one
types:
- completed # Trigger when the specified workflow is completed
jobs:
second-workflow-job: # Job to run in this workflow
runs-on: ubuntu-latest # Use the latest Ubuntu runner
steps:
- name: Second Workflow Only Step # Step to run in this job
run: echo "This is the second workflow" # Command to runView on Gist View in this repo
This setup ensures that the second workflow runs only after the first workflow has completed. The workflow_run event is used to trigger the second workflow based on the completion of the first workflow. This is particularly useful for multi-step CI/CD processes where the order of execution is crucial.