GitHub Actions Flashcards
What is GitHub Actions and the benefits of using actions? (3)
Packaged Scripts to automate tasks in a software development workflow
Benefits:
- Automate Software Development Tasks
- Facilitate CI/CD
- Integrate IaC within the projects context
What types of GH Actions Exist and where can you find them (3)
Container
JavaScript
Composite
What is the syntax to create a container, JS, and composite actions?
Docker:
“runs:
using: ‘docker’ [must be set to this]
image: ‘Dockerfiles’ [Image used as the container to run the action]”
JS
“runs:
using: ‘node12’ [application used to execute the code as defined in main’
main : ‘main.js’ [file that contains the action code]
Composite:
“runs:
using: ‘composite’
steps:
- run: ${{ github.action_path }}/test/script.sh
shell: bash”
What OSs can your run on each type of action?
Container - Must contain the env; Linux env only w/ support of a variety of languages
JavaScript - Dont include environment in code; must specify. Supports Linux, Win, Mac
Composite - Combine multiple workflows steps within one action
Define the following action syntax, is it required, and for what action types? [Part I of II]
1) Name
2) Author
3) Description
1) Name - Name of your action; Required
2) Author - Name of action author; Optional
3) Description - Short Description of Action - Required
Define the following action syntax, is it required, and for what action types? [Part II of II]
4) Inputs
5) Outputs (Composite and Container/JS)
6) Runs
7) Branding
4) Inputs - Specify data that the action expects to use during runtime; Optional
5) Outputs - Use data output from another action ran prior; Optional
5.1) Outputs for Composite - Optional
6) Runs - Declares type of action (Composite, JS, Container); Required
7) Branding - A way to personalize and distinguish your action (color, feather, etc.)
Where are github workflows stored?
”./github/workflows”
Describe the following:
- Workflows
- Jobs
- Steps
- Actions
Workflow - Automated process that you add to your repository
Jobs - Section of the workflow that will be associated with a runner
Steps - Individual task that can run commands in a job
Actions - Standalone commands that are executed
What are the four basic components of a GH workflow file? (4)
*Starting from parent downward
Workflow - Automated process that you add to you repo
Job - Associated to a runner that can run on a machine or in a container
Steps - individual tasks that can run commands in a job
Actions - Inside your workflow that are standalone commands that are executed
What is the syntax for scheduled events in a workflow? (5 fields total)
[* * * * *]
* = field
Minute [0-59]
Hour [0-23]
Day of month [1-31]
Month [1-12]
Day of week [0-6]
What are two ways to trigger a workflow manually? (2)
Workflow_dispatch; run via “Run workflow” button in the Actions Tab and all occurs within GitHub
Repository_dispatch; Trigger a workflow outside of GH via GH API HTTP POST
What are ways to trigger a workflow - high level (3)
- Manual
- Webhooks
- Scheduled
When referencing actions in your workflow what are best practices? (4)
- Specific Commit (hash value) : uses: actions/setup-node@[hash value]
- Major Version : uses: actions/setup-node@v1
- Minor Version : uses: actions/setup-node@v1.1
- Branch : uses: actions/setup-node@main
Difference between public and private actions?
Public
- Can be used by workflows in any repository
Private
- Can only be used in workflows in the same repository
How many secrets can you store within a repo, env, and org?
100 for repo & env
1000 for Org