|
1 | | -https://docs.github.com/en/actions/sharing-automations/reusing-workflowss |
| 1 | +# 06. Authoring Actions |
| 2 | + |
| 3 | +This module demonstrates how to build custom GitHub Actions and reusable workflows. Each example below has a workflow located in `.github/workflows/` following the pattern `06-authoring-actions--<name>.yaml`. |
| 4 | + |
| 5 | +## Composite Action |
| 6 | +- **Folder:** `composite-action` |
| 7 | +- **Workflow:** [`.github/workflows/06-authoring-actions--01-composite-action.yaml`](../.github/workflows/06-authoring-actions--01-composite-action.yaml) |
| 8 | +- **What it does:** defines a simple action that prints a greeting and outputs a |
| 9 | + random number. The workflow demonstrates calling the action twice in |
| 10 | + separate jobs. |
| 11 | + |
| 12 | +## Reusable Workflows |
| 13 | +- **Folder:** `reuseable-workflow` |
| 14 | +- **Workflows:** |
| 15 | + - [`.github/workflows/06-authoring-actions--02-reuseable-workflows-source.yaml`](../.github/workflows/06-authoring-actions--02-reuseable-workflows-source.yaml) – defines the reusable workflow |
| 16 | + - [`.github/workflows/06-authoring-actions--03-reuseable-workflows-caller.yaml`](../.github/workflows/06-authoring-actions--03-reuseable-workflows-caller.yaml) – calls the reusable workflow |
| 17 | + - **What they do:** the source workflow exposes inputs and secrets and prints |
| 18 | + them in a job. The caller workflow triggers manually and invokes the source |
| 19 | + workflow using both a relative path and a specific commit reference. |
| 20 | + |
| 21 | +## JavaScript & TypeScript Actions |
| 22 | +- **Folder:** `javascript-actions` |
| 23 | +- **Workflow:** [`.github/workflows/06-authoring-actions--04-javascript-actions.yaml`](../.github/workflows/06-authoring-actions--04-javascript-actions.yaml) |
| 24 | +- **What it does:** runs three jobs showcasing different approaches for |
| 25 | + JavaScript/TypeScript actions: |
| 26 | + - `javascript-action-no-build` uses vanilla Node with dependencies committed. |
| 27 | + - `javascript-action-with-build` demonstrates a Node action that normally |
| 28 | + would require a build step (pulled in as a submodule). |
| 29 | + - `typescript-action-with-build` shows a TypeScript action compiled before |
| 30 | + execution. |
| 31 | + |
| 32 | +## Container Actions |
| 33 | +- **Folder:** `container-actions` |
| 34 | +- **Workflow:** [`.github/workflows/06-authoring-actions--05-container-actions.yaml`](../.github/workflows/06-authoring-actions--05-container-actions.yaml) |
| 35 | +- **What it does:** runs three jobs that execute container-based actions: |
| 36 | + - `shell-dockerfile` builds a shell-based container action from a local |
| 37 | + Dockerfile each run. |
| 38 | + - `shell-public-container-image` reuses a prebuilt container image to skip the |
| 39 | + build step. |
| 40 | + - `python-dockerfile` builds and runs a Python action defined by a Dockerfile |
| 41 | + and prints a greeting. |
0 commit comments