Skip to content

Commit

Permalink
add workflow for chaining jobs in github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveSayantan committed Jan 21, 2025
1 parent 6f3a8c7 commit 0d03a32
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/context-and-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,8 @@ When accessing a variable, the lookup follows this order:
Hence, in the above example, the output is as follows:

```bash
value of VAR1 is myworkflowvar1
value of VAR1 is myworkflowvar1
value of VAR2 is myjobvar2
value of VAR3 is mystepvar3
```
48 changes: 48 additions & 0 deletions .github/workflows/chainingJobs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Chaining Jobs

on:
workflow_dispatch:

inputs:
run-job-3:
description: "Run job 3"
type: boolean

jobs:

job-1:
name: Job 1
runs-on: ubuntu-latest
steps:
- name: Output for Job 1
run: echo "Hello from Job 1. Run Job 3 equals ${{ github.event.inputs.run-job-3 }}"

job-2:
name: Job 2
runs-on: ubuntu-latest
needs:
- job-1
steps:
- name: Output for Job 2
run: echo "Hello from Job 2"

job-3:
name: Job 3
if: github.event.inputs.run-job-3 == 'true' # if the input is false, this job would be skipped
runs-on: ubuntu-latest
needs:
- job-1
steps:
- name: Output for Job 3
run: echo "Hello from Job 3"

job-4:
name: Job 4
runs-on: ubuntu-latest
# if: always() # Causes the job to always execute
needs:
- job-2
- job-3
steps:
- name: Output for Job 4
run: echo "Hello from Job 4"

0 comments on commit 0d03a32

Please sign in to comment.