Podcast
Questions and Answers
What is the maximum number of unique reusable workflows that can be called from a single workflow?
What is the maximum number of unique reusable workflows that can be called from a single workflow?
Which of the following statements regarding environment secrets in reusable workflows is correct?
Which of the following statements regarding environment secrets in reusable workflows is correct?
Which keyword is used to reference a reusable workflow from a caller workflow?
Which keyword is used to reference a reusable workflow from a caller workflow?
What is the correct format for referencing a reusable workflow located in the same repository?
What is the correct format for referencing a reusable workflow located in the same repository?
Signup and view all the answers
How many levels of nested reusable workflows can be established?
How many levels of nested reusable workflows can be established?
Signup and view all the answers
What are the components of a workflow in GitHub Actions?
What are the components of a workflow in GitHub Actions?
Signup and view all the answers
Which of the following options can trigger a GitHub workflow?
Which of the following options can trigger a GitHub workflow?
Signup and view all the answers
Which feature allows for the use of sensitive information in a workflow securely?
Which feature allows for the use of sensitive information in a workflow securely?
Signup and view all the answers
What is the purpose of using the 'needs' keyword in a GitHub Actions workflow?
What is the purpose of using the 'needs' keyword in a GitHub Actions workflow?
Signup and view all the answers
What does the matrix strategy feature in workflows allow you to do?
What does the matrix strategy feature in workflows allow you to do?
Signup and view all the answers
How can performance be improved when using dependencies in a workflow?
How can performance be improved when using dependencies in a workflow?
Signup and view all the answers
Which of the following options is NOT a type of workflow template provided by GitHub?
Which of the following options is NOT a type of workflow template provided by GitHub?
Signup and view all the answers
What is the purpose of using Dependabot in GitHub actions?
What is the purpose of using Dependabot in GitHub actions?
Signup and view all the answers
What practice should be avoided when using secrets in GitHub workflows?
What practice should be avoided when using secrets in GitHub workflows?
Signup and view all the answers
Which statement about redaction of secrets in logs is true?
Which statement about redaction of secrets in logs is true?
Signup and view all the answers
What is a recommended practice for managing secrets in workflows?
What is a recommended practice for managing secrets in workflows?
Signup and view all the answers
How can script injection vulnerabilities be prevented in GitHub Actions?
How can script injection vulnerabilities be prevented in GitHub Actions?
Signup and view all the answers
What should users with write access to a repository be cautious about regarding secrets?
What should users with write access to a repository be cautious about regarding secrets?
Signup and view all the answers
Which action is NOT recommended when managing secrets in workflows?
Which action is NOT recommended when managing secrets in workflows?
Signup and view all the answers
Which strategy helps to minimize risks associated with exposed tokens in workflows?
Which strategy helps to minimize risks associated with exposed tokens in workflows?
Signup and view all the answers
Which is a valid approach for configuring runners in GitHub Actions?
Which is a valid approach for configuring runners in GitHub Actions?
Signup and view all the answers
What is the primary purpose of using OpenID Connect (OIDC) in cloud access?
What is the primary purpose of using OpenID Connect (OIDC) in cloud access?
Signup and view all the answers
Which of the following is a recommended practice regarding GitHub Actions?
Which of the following is a recommended practice regarding GitHub Actions?
Signup and view all the answers
What is a significant risk when using self-hosted runners in GitHub Actions?
What is a significant risk when using self-hosted runners in GitHub Actions?
Signup and view all the answers
What type of runner is designed to enhance security by executing only one job before removal?
What type of runner is designed to enhance security by executing only one job before removal?
Signup and view all the answers
What vulnerability exists with the GITHUB_TOKEN in GitHub Actions?
What vulnerability exists with the GITHUB_TOKEN in GitHub Actions?
Signup and view all the answers
Why should personal access tokens and SSH keys be avoided?
Why should personal access tokens and SSH keys be avoided?
Signup and view all the answers
Which practice improves security by keeping actions and workflows updated in GitHub?
Which practice improves security by keeping actions and workflows updated in GitHub?
Signup and view all the answers
What does mismanagement of secrets or improper redaction in logs potentially lead to?
What does mismanagement of secrets or improper redaction in logs potentially lead to?
Signup and view all the answers
Which of the following describes a caller workflow in GitHub Actions?
Which of the following describes a caller workflow in GitHub Actions?
Signup and view all the answers
What important measure can be taken to reduce the risk of compromise in GitHub Actions?
What important measure can be taken to reduce the risk of compromise in GitHub Actions?
Signup and view all the answers
What is the primary purpose of reusable workflows?
What is the primary purpose of reusable workflows?
Signup and view all the answers
Which of the following describes job dependencies in reusable workflows?
Which of the following describes job dependencies in reusable workflows?
Signup and view all the answers
How does a caller workflow interact with a called reusable workflow?
How does a caller workflow interact with a called reusable workflow?
Signup and view all the answers
What is the benefit of defining inputs and secrets in reusable workflows?
What is the benefit of defining inputs and secrets in reusable workflows?
Signup and view all the answers
Which advantage does workflow reuse NOT provide?
Which advantage does workflow reuse NOT provide?
Signup and view all the answers
What happens if a called reusable workflow is located in a different repository?
What happens if a called reusable workflow is located in a different repository?
Signup and view all the answers
Which of the following statements is NOT true regarding calling reusable workflows?
Which of the following statements is NOT true regarding calling reusable workflows?
Signup and view all the answers
What role does workflow reuse play in promoting best practices?
What role does workflow reuse play in promoting best practices?
Signup and view all the answers
How does centralized workflows improve maintainability?
How does centralized workflows improve maintainability?
Signup and view all the answers
Which statement accurately reflects the concept of calling reusable workflows?
Which statement accurately reflects the concept of calling reusable workflows?
Signup and view all the answers
Flashcards
Reusable Workflows
Reusable Workflows
A type of workflow that can be reused across multiple workflows, allowing for code modularity and sharing.
How are reusable workflows defined?
How are reusable workflows defined?
They are defined with the 'on.workflow_call' trigger in the '.github/workflows' directory of a repository.
How do you reference reusable workflows?
How do you reference reusable workflows?
They can be referenced from a caller workflow using the 'uses' keyword in a job.
How do you pass data to reusable workflows?
How do you pass data to reusable workflows?
Signup and view all the flashcards
What is the nesting limit for reusable workflows?
What is the nesting limit for reusable workflows?
Signup and view all the flashcards
Inputs
Inputs
Signup and view all the flashcards
Outputs
Outputs
Signup and view all the flashcards
Workflow
Workflow
Signup and view all the flashcards
Workflow Triggers
Workflow Triggers
Signup and view all the flashcards
Secrets
Secrets
Signup and view all the flashcards
Matrix Strategy
Matrix Strategy
Signup and view all the flashcards
Caching Dependencies
Caching Dependencies
Signup and view all the flashcards
Caller Workflow
Caller Workflow
Signup and view all the flashcards
OpenID Connect (OIDC)
OpenID Connect (OIDC)
Signup and view all the flashcards
GitHub-Hosted Runners
GitHub-Hosted Runners
Signup and view all the flashcards
Just-in-Time (JIT) Runners
Just-in-Time (JIT) Runners
Signup and view all the flashcards
Self-Hosted Runners
Self-Hosted Runners
Signup and view all the flashcards
Full Commit SHA
Full Commit SHA
Signup and view all the flashcards
Dependabot
Dependabot
Signup and view all the flashcards
Repository Deploy Keys
Repository Deploy Keys
Signup and view all the flashcards
GitHub App Tokens
GitHub App Tokens
Signup and view all the flashcards
Workflow Reuse
Workflow Reuse
Signup and view all the flashcards
Job Dependencies
Job Dependencies
Signup and view all the flashcards
Workflow Context
Workflow Context
Signup and view all the flashcards
Inputs in Reusable Workflows
Inputs in Reusable Workflows
Signup and view all the flashcards
Secrets in Reusable Workflows
Secrets in Reusable Workflows
Signup and view all the flashcards
Dependency Graph in GitHub Actions
Dependency Graph in GitHub Actions
Signup and view all the flashcards
Inputs and Secrets Definition
Inputs and Secrets Definition
Signup and view all the flashcards
Labels for Runners
Labels for Runners
Signup and view all the flashcards
Using Secrets
Using Secrets
Signup and view all the flashcards
Redaction
Redaction
Signup and view all the flashcards
Best Practices: Avoid Structured Data
Best Practices: Avoid Structured Data
Signup and view all the flashcards
Best Practices: Register Derived Secrets
Best Practices: Register Derived Secrets
Signup and view all the flashcards
Best Practices: Audit and Review Secrets
Best Practices: Audit and Review Secrets
Signup and view all the flashcards
Best Practices: Least Privilege Credentials
Best Practices: Least Privilege Credentials
Signup and view all the flashcards
Best Practices: Rotate Secrets
Best Practices: Rotate Secrets
Signup and view all the flashcards
Access Controls: Secret Visibility
Access Controls: Secret Visibility
Signup and view all the flashcards
Access Controls: CODEOWNERS
Access Controls: CODEOWNERS
Signup and view all the flashcards
Access Controls: Environment Secret Review
Access Controls: Environment Secret Review
Signup and view all the flashcards
Risk of Script Injection
Risk of Script Injection
Signup and view all the flashcards
Mitigation: Using Actions
Mitigation: Using Actions
Signup and view all the flashcards
Mitigation: Using Environment Variables
Mitigation: Using Environment Variables
Signup and view all the flashcards
Mitigation: Defensive Programming
Mitigation: Defensive Programming
Signup and view all the flashcards
Security Enhancements: Code Scanning
Security Enhancements: Code Scanning
Signup and view all the flashcards
Security Enhancements: Token Permissions
Security Enhancements: Token Permissions
Signup and view all the flashcards
Study Notes
Key Components
- Workflows: Configurable processes defined in YAML files, triggered by events (repository activities, manual, schedule). Can perform tasks like building, testing, deploying code, or labeling issues.
- Events: Specific repository activities (e.g., creating a pull request, pushing a commit) that trigger workflows.
- Jobs: A sequence of steps executed on a single runner. Jobs can be run independently in parallel or have dependencies on other jobs.
- Actions: Reusable custom applications for performing repetitive tasks (e.g., setting up environments or cloud authentication). Available in GitHub Marketplace or custom-built.
- Runners: Servers that execute workflows, each runner running one job at a time. GitHub provides Linux, Windows, and macOS virtual runners, or self-hosted runners can be used for custom configurations.
Capabilities and Use Cases
- Automate builds, tests, deployments.
- Build CI/CD (Continuous Integration/Continuous Delivery) pipelines.
- Run workflows on GitHub-hosted or self-hosted environments.
Key Features of Actions
- Reusable: Actions can be used across multiple workflows and repositories.
- Pre-written: Many community-created actions are available in the GitHub Marketplace.
Types of Actions
- Same Repository: Actions stored in the same repository as the workflow.
- Public Repository: Actions from any public repository.
- Docker Containers: Actions defined as Docker images on Docker Hub.
Using Actions in Workflows
- Browsing GitHub Marketplace: Use the workflow editor to find and add actions, which may have a checkmark badge indicating verification by GitHub.
- Adding Actions to a Workflow: Add actions as steps in the workflow file (.yml). Use owner/repo@{version} (or ./path/to/dir) to reference external/local actions.
Versioning Actions
- Tags: Use tags (e.g., v1.0.1) to specify a version.
- SHAs: Use immutable SHA values for greater reliability.
- Branches: Use branches, but be aware that this might include breaking changes.
Inputs and Outputs
- Inputs: Actions can require inputs, specifying data needed (e.g., file paths).
- Outputs: Actions can provide outputs, allowing for results to be used in other workflows.
Security and Best Practices
- Dependabot: Use Dependabot for keeping actions updated.
- SHAs for Actions: Prefer SHAs over other references for actions to ensure security.
- Docker Image Verification: Verify Docker images when using Docker actions.
Workflow Basics
- Triggers: Events that start the workflow (e.g., push, pull request, issue creation).
- Jobs: Units of work run on a runner.
- Steps: Actions or scripts executed sequentially in a job.
Workflow Triggers
- Repository Events: Pushes, releases, issue creation.
- External Events: Triggered via repository_dispatch.
- Schedules: Using cron syntax.
- Manual Triggers: Via the GitHub interface.
Workflow Templates
- GitHub offers templates for workflows (CI, Deployments, Automation, Code Scanning, Pages).
- Templates are customizable for project-specific needs.
Advanced Workflow Features
- Secrets: Store sensitive data securely as environment variables.
- Dependent Jobs: Use the
needs
keyword to create dependencies between jobs. - Matrix Strategy: Run jobs with different configurations (e.g., Node.js versions).
- Caching Dependencies: Improve performance by caching reusable files.
- Service Containers: Run temporary containers (e.g., databases) alongside jobs.
Labels for Runners
- Use labels to specify runner types (self-hosted, Linux, macOS).
Reusable Workflows
- Call workflows within other workflows to avoid duplication.
Security Features
- Dependabot: Use Dependabot to track and update actions.
- Environment Configuration: Configure environments with protection rules for secrets to control job execution.
Using Secrets
- Secrets are encrypted using Libsodium sealed boxes before reaching GitHub, minimizing accidental leaks.
- Secrets can be configured at the organization, repository, or environment level.
Best Practices
- Avoid structured data (JSON, XML, YAML) as secrets.
- Register all derived secrets.
- Regularly audit and review secret usage, ensuring redaction in logs.
- Use least privilege (minimal permissions) for credentials.
- Rotate secrets periodically.
Access Controls
- Only users with write access can view secrets.
- Use
CODEOWNERS
to restrict workflow changes. - Consider requiring review approvals for environment secrets.
Risks of Script Injection
- Use actions instead of inline scripts to avoid code execution vulnerabilities.
Security Enhancements
- Use workflow templates for code scanning.
- Restrict token permissions for minimizing risk.
- Use OpenID Connect (OIDC) for cloud access (instead of long-lived credentials).
Warnings
- Users with write access can read all secrets.
- Poor log management can lead to accidental secret leaks.
Risks of Third-Party Actions
- Pin actions to a commit SHA for immutability and backdoor prevention.
- Audit action source code for misuse of secrets.
- Pin actions to a tag if trusted, but be aware of potential tag deletion/movement.
- Use Dependabot to help keep actions up to date.
Compromised Runner Risks
- Accessing secrets can be risky.
- Exfiltrating data from logs or HTTP requests exposes secrets.
- Stealing the
GITHUB_TOKEN
exposes secrets and gives malicious actors write access.
GitHub Action Runner Types
- GitHub-hosted runners run in isolated environments, reducing compromise risk.
- Self-hosted runners are more susceptible to compromise.
Security Measures
- Use
GITHUB_TOKEN
for repository-specific access. - Use Repository Deploy Keys and GitHub App Tokens.
- Avoid Personal Access Tokens and SSH keys.
- Use OpenID Connect for cloud deployments.
Reusing Workflows
- Reusable workflows in GitHub Actions are key for code reuse and maintenance.
- Caller Workflow: The workflow that calls a reusable workflow.
- Called Workflow: The reusable workflow that is called.
- Reusability improves maintainability and consistency.
Reusable Workflow Setup
- Reusable workflows take inputs and secrets.
- Input and secret data types should match the workflow definition.
- Secrets are used in actions within the reusable workflow.
Calling Reusable Workflows
- Use the
uses
keyword to call a reusable workflow. - Pass inputs and secrets using the
with
andsecrets
keywords in the call.
Security Considerations
- Trust the version of the reusable workflow.
- Environment secrets cannot be passed directly from the caller.
Re-running Workflows
- Re-running a workflow reuses the SHA reference (or latest branch/tag).
- If not a SHA, the latest reference is used.
Key Points
- Reusable workflows reduce duplication, ensuring consistency across workflows.
- Inputs, secrets, outputs, and monitoring tools enhance workflow execution.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Explore the key components and capabilities of GitHub Actions in automating workflows. Learn how workflows, events, jobs, actions, and runners work together to enhance software development efficiency. Ideal for developers looking to streamline their CI/CD processes.