GitHub Actions Fundamentals
GitHub Actions makes it easy to automate all your software workflows, right from GitHub.
Core Concepts
- Workflows: Automated processes defined in a YAML file in the
.github/workflowsdirectory. - Events: Triggers that run workflows (e.g.,
push,pull_request). - Jobs: A set of steps that execute on the same runner.
- Steps: Individual tasks that can run commands or actions.
- Actions: Standalone commands that are combined into steps to create a job.
- Runners: Servers that run your workflows when they’re triggered.
Example Workflow
name: CI
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run a one-line script
run: echo Hello, world!Managing Secrets
GitHub provides encrypted secrets to store sensitive information like API keys and tokens. These can be accessed in workflows using the ${{ secrets.SECRET_NAME }} syntax.