Open reboottime opened 1 week ago
Topic | Description |
---|---|
What is GitHub Actions | A(custom) application that performs a (typically complex) frequently repeated task. The alternative to Github action is command (run) |
CI & CD | Continuous Integration and Continuous Delivery • CI: Code changes are automatically built, tested & merged with existing code • CD: After integration, new app or package versions are published automatically |
Repository Automation Area | Code deployment: Automate code testing, building, and deployment |
Key Element | Characteristics |
---|---|
Workflows | • Attached to a GitHub repository • Contain one or more Jobs • Triggered upon Events |
Jobs | • Define a Runner (execution environment) • Contain one or more steps • Run in parallel (default) or sequential • Can be conditional |
Steps | • Execute a shell script or an Action • Can use custom or third-party actions • Steps are executed in order • Can be conditional |
Runner | the environment that runs the actions. Every job gets its own runner - its own virtual machine that's totally isolated from other machines and jobs |
Category | Event | Description |
---|---|---|
Repository-related | push | Pushing a commit |
fork | Repository was forked | |
watch | Repository was starred | |
pull_request | Pull request action (opened, closed, ...) | |
issues | An issue was opened, deleted, ... | |
discussion | Discussion action (created, deleted, ...) | |
create | A branch or tag was created | |
issue_comment | Issue or pull request comment action | |
Other | workflow_dispatch | Manually trigger workflow |
repository_dispatch | REST API request triggers workflow | |
schedule | Workflow is scheduled | |
workflow_call | Can be called by other workflows |
run: |
echo "First output"
echo "Second output"
This will run both commands in one step.
[skip_ci]
in your code commit. Github actions can recognize it and skips workflowJob Artifacts are stuff output by a job. See explanation below:
Job Artifacts | Output Asset(s) | Use Cases |
---|---|---|
Job (Example: Build app) | Example: App binary, website files etc. | 1. Download & Use Manually Via GitHub UI Or REST API 2. Download & Use in other Jobs Via Action |
A following job can use the previous step(s) artifacts. Here is how:
Upload current step's artifacts to somewhere
name: Save artifacts uses: actions/upload-artifact@v4 with: name: build # define the artifacts name path: build # define the file paths to upload
Use artifacts from previous step(s)
name: Download artifacts uses: actions/download-artifact@v4 with: name: build # get the artifacts uploaded from previous job
A full example can be found at 5.yml
As you can see in the 05.yml
file, there are some repetitive steps between jobs. For example:
In this repository, the package manager is `pnpm`.
Concept | Description |
---|---|
Artifacts | - Jobs often produce assets that should be shared or analyzed - Examples: Deployable website files, logs, binaries etc. - These assets are referred to as "Artifacts" (or "Job Artifacts") - GitHub Actions provides Actions for uploading & downloading |
Outputs | - Besides Artifacts, Steps can produce and share simple values - These outputs are shared via ::set-output - Jobs can pick up & share step outputs via the steps context - Other Jobs can use Job outputs via the needs context |
Caching | - Caching can help speed up repeated, slow Steps - Typical use-case: Caching dependencies - But any files & folders can be cached - The cache Action automatically stores & updates cache values - (based on the cache key) |
Overview
This article talks about the major concepts of using Github action as a CI CD solution.
Major concepts are bellow
Credits to Claude.ai to refine my English grammars and content.