Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 10 additions & 10 deletions .github/workflows/03-core-features--01-hello-world.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Hello World

on:
workflow_dispatch:

jobs:
say-hello-inline-bash:
runs-on: ubuntu-24.04
steps:
- run: echo "Hello from an inline bash script in a GitHub Action Workflow!"
name: Hello World
on:
workflow_dispatch:
jobs:
say-hello-inline-bash:
runs-on: ubuntu-24.04
steps:
- run: echo "Hello from an inline bash script in a GitHub Action Workflow!"
48 changes: 24 additions & 24 deletions .github/workflows/03-core-features--02-step-types.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
name: Step Types

on:
workflow_dispatch:

jobs:
say-hello-inline-bash:
runs-on: ubuntu-24.04
steps:
- run: echo "Hello from an inline bash script in a GitHub Action Workflow!"

say-hello-inline-python:
runs-on: ubuntu-24.04
steps:
- run: print("Hello from an inline python script in a GitHub Action Workflow!")
shell: python

say-hello-action:
runs-on: ubuntu-24.04
steps:
- uses: actions/hello-world-javascript-action@081a6d193d1dcb38460df1e6927486d748730f9d # v1.1
# - uses: actions/hello-world-javascript-action@v1 # This would work, but it would be less stable and less secure:
with:
who-to-greet: "from an action in the GitHub Action marketplace! 👋"
name: Step Types
on:
workflow_dispatch:
jobs:
say-hello-inline-bash:
runs-on: ubuntu-24.04
steps:
- run: echo "Hello from an inline bash script in a GitHub Action Workflow!"
say-hello-inline-python:
runs-on: ubuntu-24.04
steps:
- run: print("Hello from an inline python script in a GitHub Action Workflow!")
shell: python
say-hello-action:
runs-on: ubuntu-24.04
steps:
- uses: actions/hello-world-javascript-action@081a6d193d1dcb38460df1e6927486d748730f9d # v1.1
# - uses: actions/hello-world-javascript-action@v1 # This would work, but it would be less stable and less secure:
with:
who-to-greet: "from an action in the GitHub Action marketplace! 👋"
60 changes: 30 additions & 30 deletions .github/workflows/03-core-features--03-workflows-jobs-steps.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
name: Workflows, Jobs, and Steps

on:
workflow_dispatch:
jobs:
job-1:
runs-on: ubuntu-24.04
steps:
- run: echo "A job consists of"
- run: echo "one or more steps"
- run: echo "which run sequentially"
- run: echo "within the same compute environment"
job-2:
runs-on: ubuntu-24.04
steps:
- run: echo "Multiple jobs can run in parallel"
job-3:
runs-on: ubuntu-24.04
needs:
- job-1
- job-2
steps:
- run: echo "They can also depend on one another..."
job-4:
runs-on: ubuntu-24.04
needs:
- job-2
- job-3
steps:
- run: echo "...to form a directed acyclic graph (DAG)"
name: Workflows, Jobs, and Steps
on:
workflow_dispatch:
jobs:
job-1:
runs-on: ubuntu-24.04
steps:
- run: echo "A job consists of"
- run: echo "one or more steps"
- run: echo "which run sequentially"
- run: echo "within the same compute environment"
job-2:
runs-on: ubuntu-24.04
steps:
- run: echo "Multiple jobs can run in parallel"
job-3:
runs-on: ubuntu-24.04
needs:
- job-1
- job-2
steps:
- run: echo "They can also depend on one another..."
job-4:
runs-on: ubuntu-24.04
needs:
- job-2
- job-3
steps:
- run: echo "...to form a directed acyclic graph (DAG)"
76 changes: 38 additions & 38 deletions .github/workflows/03-core-features--04-triggers-and-filters.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
name: Triggering Events
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows

on:
### https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#push
push:
branches:
# Filter patterns cheat sheet:
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
- "example-branch/*"

### https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request
pull_request:
## The default is to trigger on the following types of events:
types:
- opened
- synchronize
- reopened
paths:
# include markdown files
- "03-core-features/filters/*.md"
# Exclude txt files
- "!03-core-features/filters/*.txt"

### https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#schedule
# schedule:
# - cron: "0 0 * * *" # Midnight UTC

## Manual Trigger
workflow_dispatch:
jobs:
echo-event:
runs-on: ubuntu-24.04
steps:
- name: Dump full event JSON
run: |
echo "=== $GITHUB_EVENT_NAME payload ==="
cat "$GITHUB_EVENT_PATH"
name: Triggering Events
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
on:
### https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#push
push:
branches:
# Filter patterns cheat sheet:
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
- "example-branch/*"
### https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request
pull_request:
## The default is to trigger on the following types of events:
types:
- opened
- synchronize
- reopened
paths:
# include markdown files
- "03-core-features/filters/*.md"
# Exclude txt files
- "!03-core-features/filters/*.txt"
### https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#schedule
# schedule:
# - cron: "0 0 * * *" # Midnight UTC
## Manual Trigger
workflow_dispatch:
jobs:
echo-event:
runs-on: ubuntu-24.04
steps:
- name: Dump full event JSON
run: |
echo "=== $GITHUB_EVENT_NAME payload ==="
cat "$GITHUB_EVENT_PATH"
68 changes: 34 additions & 34 deletions .github/workflows/03-core-features--05-environment-variables.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
name: Environment Variables
on:
workflow_dispatch:
env:
WORKFLOW_VAR: I_AM_WORKFLOW_SCOPED

jobs:
job-1:
runs-on: ubuntu-24.04
env:
JOB_VAR: I_AM_JOB_1_SCOPED
steps:
- name: Inspect scopes job 1 step 1
env:
STEP_VAR: I_AM_STEP_SCOPED
run: |
echo "WORKFLOW_VAR: $WORKFLOW_VAR" # visible
echo "JOB_VAR: $JOB_VAR" # visible
echo "STEP_VAR: $STEP_VAR" # visible only here

- name: Inspect scopes job 1 step 2
run: |
echo "WORKFLOW_VAR: $WORKFLOW_VAR" # visible
echo "JOB_VAR: $JOB_VAR" # visible
echo "STEP_VAR: ${STEP_VAR:-<UNSET>}" # not set here

job-2:
runs-on: ubuntu-24.04
steps:
- name: Inspect scopes job 2 step 2
run: |
echo "WORKFLOW_VAR: $WORKFLOW_VAR" # still visible
echo "JOB_VAR: ${FOO:-<UNSET>}" # not set here
echo "STEP_VAR: ${STEP_VAR:-<UNSET>}" # not set here
name: Environment Variables
on:
workflow_dispatch:
env:
WORKFLOW_VAR: I_AM_WORKFLOW_SCOPED
jobs:
job-1:
runs-on: ubuntu-24.04
env:
JOB_VAR: I_AM_JOB_1_SCOPED
steps:
- name: Inspect scopes job 1 step 1
env:
STEP_VAR: I_AM_STEP_SCOPED
run: |
echo "WORKFLOW_VAR: $WORKFLOW_VAR" # visible
echo "JOB_VAR: $JOB_VAR" # visible
echo "STEP_VAR: $STEP_VAR" # visible only here
- name: Inspect scopes job 1 step 2
run: |
echo "WORKFLOW_VAR: $WORKFLOW_VAR" # visible
echo "JOB_VAR: $JOB_VAR" # visible
echo "STEP_VAR: ${STEP_VAR:-<UNSET>}" # not set here
job-2:
runs-on: ubuntu-24.04
steps:
- name: Inspect scopes job 2 step 2
run: |
echo "WORKFLOW_VAR: $WORKFLOW_VAR" # still visible
echo "JOB_VAR: ${FOO:-<UNSET>}" # not set here
echo "STEP_VAR: ${STEP_VAR:-<UNSET>}" # not set here
70 changes: 35 additions & 35 deletions .github/workflows/03-core-features--06-passing-data.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
name: Passing Variables Between jobs
on:
workflow_dispatch:

jobs:
producer:
runs-on: ubuntu-24.04

outputs:
foo: ${{ steps.generate-foo.outputs.foo }}
steps:
- name: Generate and export foo
id: generate-foo
run: |
foo=bar

# 1) Step output (for job output)
echo "foo=${foo}" >> "$GITHUB_OUTPUT"

# 2) Job-scoped environment variable
echo "FOO=${foo}" >> "$GITHUB_ENV"

- name: Inspect values inside producer
run: |
echo "FOO (set via GITHUB_ENV): $FOO"
echo "foo (step output): ${{ steps.generate-foo.outputs.foo }}"

consumer:
runs-on: ubuntu-24.04
needs: producer
steps:
- name: Inspect values inside consumer (note FOO is unset)
run: |
echo "Value from producer: ${{ needs.producer.outputs.foo }}"
echo "FOO in consumer: ${FOO:-<UNSET>}"
name: Passing Variables Between jobs
on:
workflow_dispatch:
jobs:
producer:
runs-on: ubuntu-24.04
outputs:
foo: ${{ steps.generate-foo.outputs.foo }}
steps:
- name: Generate and export foo
id: generate-foo
run: |
foo=bar
# 1) Step output (for job output)
echo "foo=${foo}" >> "$GITHUB_OUTPUT"
# 2) Job-scoped environment variable
echo "FOO=${foo}" >> "$GITHUB_ENV"
- name: Inspect values inside producer
run: |
echo "FOO (set via GITHUB_ENV): $FOO"
echo "foo (step output): ${{ steps.generate-foo.outputs.foo }}"
consumer:
runs-on: ubuntu-24.04
needs: producer
steps:
- name: Inspect values inside consumer (note FOO is unset)
run: |
echo "Value from producer: ${{ needs.producer.outputs.foo }}"
echo "FOO in consumer: ${FOO:-<UNSET>}"
Loading