Introduction to GitHub Actions – How to easily automate and integrate with GitHub

All Things Open
All Things OpenAll Things Open
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
2
© 2022 Brent C. Laster &
Tech Skills Transformations & Brent Laster
Introduction to GitHub Actions
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
3
© 2022 Brent C. Laster &
About me
• R&D Director, DevOps
• Global trainer – training (Git,
Jenkins, Gradle, CI/CD,
pipelines, Kubernetes,
Helm, ArgoCD, operators)
• Author -
§ OpenSource.com
§ Professional Git book
§ Jenkins 2 – Up and
Running book
§ Mini-books on O'Reilly
§ GitHub Actions book
(coming in 2023 - early
preview on O'Reilly)
techskillstransformations.com
getskillsnow.com
https://www.linkedin.com/in/brentlaster
@BrentCLaster
GitHub: brentlaster
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
4
© 2022 Brent C. Laster &
Book – Professional Git
• Extensive Git reference,
explanations, and examples
• First part for non-technical
• Beginner and advanced
reference
• Hands-on labs
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
5
© 2022 Brent C. Laster &
Jenkins 2 Book
• Jenkins 2 – Up and Running
• “It’s an ideal book for those who are
new to CI/CD, as well as those who
have been using Jenkins for many
years. This book will help you discover
and rediscover Jenkins.” By Kohsuke
Kawaguchi, Creator of Jenkins
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
6
© 2022 Brent C. Laster &
Learning GitHub Actions - Early Release
• Early release - Chapters 1 & 2 on learning.oreilly.com
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
7
© 2022 Brent C. Laster &
ATO 2022
Session: Cloud-native CI/CD in Kubernetes with Tekton
Tekton is a newer entry in the CI/CD tooling space that allows you to implement CI/CD
pipelines through custom Kubernetes objects. Because of that, you can utilize the
same Kubernetes knowledge you already have without learning another application
and take advantage of your existing Kubernetes infrastructure and features such as
scaling that are built in. Join author and trainer and DevOps Director Brent Laster to
learn how to easily and quickly get up to speed with Tekton and the supporting pieces
around it including its dashboard and CLI.
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
8
© 2022 Brent C. Laster &
O’Reilly Training
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
9
© 2022 Brent C. Laster &
NFJS Training
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
10
© 2022 Brent C. Laster &
What are GitHub Actions?
• Way to create custom, automated workflows in GitHub
• Executed based on repository operations
• Building blocks - can be combined & shared
• Used for usual SDLC tasks
• Can be used for CI/CD as alternatives to other apps
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
11
© 2022 Brent C. Laster &
Example use cases (starter workflows)
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
12
© 2022 Brent C. Laster &
What's interesting about it?
• Direct integration with GitHub
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
13
© 2022 Brent C. Laster &
What else is interesting about it?
• Lots of events can trigger an action workflow -
automate practically anything!
on: project
on: watch
on: repository_dispatch
on: delete
on: check_run
on: page_build
on: scheduled
on: pull_request
on: public
on: pull_request_review_comment
on: pull_push
on: fork
https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
14
© 2022 Brent C. Laster &
Types of triggers for events
• single event - on: push
• list of events - on: [push, pull_request]
• specify activity types or configuration - on:
push:
branches:
- main
• scheduled events - on:
scheduled:
- cron: '30 5,15 * * *'
• manual events - on: workflow-dispatch
on: repository-dispatch
[opened, deleted]
• workflow reuse events - on: workflow-call
(can be called from another workflow)
• webhook events - on: issue_comment
on: pull_request
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
15
© 2022 Brent C. Laster &
How Actions work (events)
• Events occur
§ Example: pull request
triggers build for
validation
§ Example: push for
commit
• Repository Dispatch
Events
§ Endpoint that can be
used to trigger webhook
event
§ Can be used for activity
that is not in GitHub
§ Can trigger a GitHub
Actions workflow or
GitHub App webhook
• ref
https://docs.github.com
/en/rest/reference/repo
s#create-a-repository-
dispatch-event
Event
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
16
© 2022 Brent C. Laster &
How Actions work (workflows)
• Events trigger workflows
workflow
Event
§ Procedure to run
automatically
§ Added to your repository
§ Composed of one+ jobs
§ Can be triggered/scheduled
by event
§ Useful for doing CI/CD
actions such as building,
testing, packaging, etc.
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
17
© 2022 Brent C. Laster &
How actions work (jobs, steps, actions, shell cmds)
Workflows contain jobs
§ Set of steps
§ Workflow with multiple jobs runs them in parallel
Jobs contain steps
§ A task that can execute commands in a job
§ Can be either
» action
» shell command
workflow
Job 1
Job 2
Event
Step 1
Step 1
Step 2
action or
shell cmd
action
§ Independent
commands
§ Based off repository
in GitHub
§ Used in steps to
form a job
§ Smallest unit in a
workflow
§ Can be created or
pulled in from the
community
§ Only usable if
included as a step
action or
shell cmd
action or
shell cmd
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
18
© 2022 Brent C. Laster &
How Actions work (runner)
Runner
• A server with GitHub
Actions runner app
on it
• Can use runner
provided by/hosted
via GitHub or use
your own
• Runner listens for
available jobs
• Steps in a job execute
on the same runner
workflow
Job 1
Job 2
Event
Step 1
Step 1
Step 2
Runner 1
action or cmd
runs
Runner 2
action or cmd
runs
logs results
logs results
action or
shell cmd
action or
shell cmd
action or
shell cmd
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
19
© 2022 Brent C. Laster &
How actions work
GitHub Repository
.github
workflows
workflow1.yml
Job 1
Step 1
Step 2
Job 2
Step 1
workflow2.yml
Job 1
Step 1
Job 2
Step 1
Step 2
Runner 1
Runner 2
Event
• Resides in
.github/workflows
• Can have multiple
workflows
action or
shell cmd
action or
shell cmd
action or
shell cmd
action or
shell cmd
action or
shell cmd
action or
shell cmd
action or cmd
runs
logs results
action or cmd
runs
logs results
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
20
© 2022 Brent C. Laster &
GitHub-hosted vs Self-hosted Runners
GitHub-hosted Self-hosted
Definition Hosted by GitHub Any system/configuration
you want to use
Prereqs Running GitHub actions
runner application
GitHub actions self-hosted
runner application
Platforms Windows, Linux, MacOS Any that can be made to
work
Advantages Quicker and simpler Highly configurable
Management/Ownership GitHub As defined
Clean instance For every job execution Optional
Cost Free minutes on GitHub
plan with cost for overages
Free to use with actions,
but owner is responsible
for any other cost
Automatic updates For OS, installed packages,
tools, and hosted runner
application
Only for self-hosted runner
application
Implementation Virtual Virtual or physical
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
21
© 2022 Brent C. Laster &
GitHub Actions Runners
• Virtual
environments for
GitHub actions
hosted runners
• New VM for each
job run
• VM images of
Microsoft-hosted
agents used for
Azure Pipelines
• Updated
periodically by
GitHub
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
22
© 2022 Brent C. Laster &
Self-hosted Runners
• Useful when you need more configurability
and control
• Allows you to choose and customize
configuration, system resources, available
software, etc.
• Can be physical systems, VMs, containers, on-
prem or cloud
• Runner system connects to GitHub via GitHub
Actions self-hosted runner
• Automatically kicked off of GitHub if no
connection to GitHub Actions after 30 days
• Recommended to use only with private repos
§ Forks of repos could run dangerous code on self-
hosted runner machine (via PR that executes code
in workflow)
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
23
© 2022 Brent C. Laster &
GitHub Actions Storage - Artifacts
• Actions allow you to persist data after job has completed - as artifacts
• Artifact - file or collection of files produced during workflow run
§ build and test output
§ log files
§ binary files
• Artifacts are uploaded during workflow run
§ can be shared between jobs in same workflow
§ visible in the UI
• Default retention period is 90 days
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
24
© 2022 Brent C. Laster &
How much does it cost? (part 1)
• Free for public repos and/or self-hosted runners
• For private repos, each GitHub account gets
designated amount of free minutes and storage
§ above that, usage is controlled by spending limits
§ minutes reset every month, but not storage
Product Storage Minutes (per month)
GitHub Free 500 MB 2,000
GitHub Pro 1 GB 3,000
GitHub Free for
organizations
500 MB 2,000
GitHub Team 2 GB 3,000
GitHub Enterprise
Cloud
50 GB 50,000
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
25
© 2022 Brent C. Laster &
How much does it cost? (part 2)
• Total storage is Actions artifacts and GitHub Packages
§ GitHub Packages = platform for hosting and managing packages, such as containers or
dependencies
• Storage usage is calculated for each month based on hourly usage during the month
• Per-minute rates
• If jobs run on Windows or macOS on runners hosted by GitHub, multiplier comes into play
Operating system Minute multiplier
Linux 1
macOS 10
Windows 2
Operating system Per-minute rate
(USD)
Linux $0.008
macOS $0.08
Windows $0.016
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
26
© 2022 Brent C. Laster &
Integration with GitHub Interface
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
27
© 2022 Brent C. Laster &
Viewing Logs
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
28
© 2022 Brent C. Laster &
Viewing the Workflow Run history
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
29
© 2022 Brent C. Laster &
Filtering workflows
• Enter text in search bar
• Click on "x" at end to
clear
• Click on category in
"workflow run results"
bar
• Select from the list
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
30
© 2022 Brent C. Laster &
Viewing a Specific Workflow Run
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
31
© 2022 Brent C. Laster &
Job Graph
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
32
© 2022 Brent C. Laster &
Drilling into logs
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
33
© 2022 Brent C. Laster &
Editing Workflows
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
34
© 2022 Brent C. Laster &
Editing with VSCode
• Hit "." when in file
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
35
© 2022 Brent C. Laster &
Updating workflows with Pull Requests #1
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
36
© 2022 Brent C. Laster &
Running your workflow manually
• Add a "workflow dispatch event" trigger
• Merge changes
• Afterwards will have "Run workflow" button in
workflow list
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
37
© 2022 Brent C. Laster &
Public Actions
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
38
© 2022 Brent C. Laster &
Searching for a Public Action
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
39
© 2022 Brent C. Laster &
Actions use Workflows
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
40
© 2022 Brent C. Laster &
Action Metadata File
• action.yml or
action.yaml
• defines inputs,
outputs, runtime
env, config, branding
• must be present to
have an action
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
41
© 2022 Brent C. Laster &
Custom Actions
• Can be created by you
• Can result from customizing community actions
• Can be put on Marketplace and shared
• repository must be public
• Can integrate with any public API
• Can run directly on a machine or in Docker
container
• Can define inputs, outputs, and environment
variables
• Require metadata file
• defines inputs, outputs, and entrypoint
• must be named either action.yaml or
action.yml
• Should be tagged with a label and then pushed to
GitHub
• To use:
• In file in .github/workflows/main.yml
• In steps
• "uses: <github path to action>@<label>
$ <create GitHub repo>
$ <clone repo>
$ <create files>
$ git add action.yml <other files>
$ git commit -m "action files"
$ git tag -a -m "first release of action" v1
$ git push --follow-tags
on: [push]
jobs:
example_job:
runs on: ubuntu-latest
name: An example job
steps:
- name: Example step
id: example_step
uses: <repo name>/<action name>@<tag>
...
.github/workflows/example.yml
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
42
© 2022 Brent C. Laster &
Custom Action Types
• Docker
• Packages env with actions code
• Env can include specific OS versions,
config, tools, etc.
• Well suited for specific env needs
• Runs only on Linux runners with
Docker installed
• Slower due to cost of building and
retrieving container
• GitHub builds image from Dockerfile
and runs comands in a new
container based on image
• Javascript
• Run directly on runner for any of
macOS, Linux, or Windows
• Separates action from env
• Fast than Docker
• Needs to be pure JavaScript (no
other binaries)
• Can use binaries already on runner
• Composite
• Combines multiple workflow steps
in one action
Runner
FROM <base> ....
COPY <entry script>
ENTRYPOINT <script>
Dockerfile
...
runs:
using: 'docker'
image: 'Dockerfile'
args:
....
action.yml
+ +
Runner
+ +
...
runs:
using: 'node12'
main: 'index.js'
action.yml
npm install @actions/core
npm install @actions/github
const core =
require('@actions/core');
const github =
require('@actions/github);
try{
...
} catch (error) {
...
}
index.js
Runner
...
runs:
using: 'composite'
- run: echo ...
- run: ${{ github.action.path
}}/shell-script.sh
action.yml
+
echo ...
...
shell-script.sh
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
43
© 2022 Brent C. Laster &
Workflow commands
• Used to communicate with the runner machine to
§ Set environment variables
§ Set output values used by other actions
§ Add debug messages to logs
• Typically use "echo" command with certain format
• Also can be used to execute some commands in
Actions Toolkit
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
44
© 2022 Brent C. Laster &
Actions Toolkit
• Provides packages for more
easily creating/working with
actions
• Functions in packages can be
run in code as in
core.setOutput('SELECTED_COLOR
', 'red');
or (in many cases)
• run as workflow commands
- name: Set selected color run:
echo '::set-output
name=SELECTED_COLOR::green'
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
45
© 2022 Brent C. Laster &
Actions Toolkit packages
• Collections of
related
functions
• Can be
imported into
code for actions
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
46
© 2022 Brent C. Laster &
Monitoring and Troubleshooting
• Use "default" information
§ Visualization graph of a workflow
§ Workflow run history
§ Workflow logs
§ Dump out the runner context
§ Enable debug logging
» can use core.debug or "echo
"::debug:: <message>"
» must be enabled via setting up
secrets
» ACTIONS_RUNNER_DEBUG
» ACTIONS_STEP_DEBUG
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
47
© 2022 Brent C. Laster &
Enabling/Creating Secrets for Actions
• Create in same repo, so same permissions needed
1
2
3
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
48
© 2022 Brent C. Laster &
Defining Secrets for Actions
• Provide secret name
• Provide value
• Add secret
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
49
© 2022 Brent C. Laster &
GitHub Personal Access Token
• Provides specific accesses
• Replaces passwords
• Can be done through https://github.com/settings/tokens
• Or can be setup via Settings->Profile->Developer Settings->Personal Access Tokens
• Generate new token and save it
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
50
© 2022 Brent C. Laster &
Workflows invoking GitHub
• Workflows can
invoke GitHub or
other
functionality via
techniques such
as curl
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
51
© 2022 Brent C. Laster &
Chaining Workflows Together
• Can be done via GitHub API calls
• Requires API Token saved as a secret
• One workflow then invokes the other via API call
create-issue-on-failure:
runs-on: ubuntu-latest
needs: [test-run, count-args]
if: always() && failure()
steps:
- name: invoke workflow to create issue
run: >
curl -X POST
-H "authorization: Bearer ${{ secrets.WORKFLOW_USE }}"
-H "Accept: application/vnd.github.v3+json"
"https://api.github.com/repos/${{ github.repository }}/actions/workflows/create-failure-issue.yml/dispatches"
-d '{"ref":"main",
"inputs":
{"title":"Automated workflow failure issue for commit ${{ github.sha }}",
"body":"This issue was automatically created by the GitHub Action workflow ** ${{ github.workflow }} **"}
}'
techupskills.com | techskillstransformations.com
© 2021 Brent C. Laster &
@techupskills
52
© 2022 Brent C. Laster &
That’s all - thanks!
techskillstransformations.com
getskillsnow.com
1 sur 51

Recommandé

Intro to GitHub Actions par
Intro to GitHub ActionsIntro to GitHub Actions
Intro to GitHub ActionsAll Things Open
187 vues52 diapositives
Introduction to GitHub Actions par
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub ActionsAll Things Open
31 vues65 diapositives
Introduction to GitHub Actions - How to easily automate and integrate with Gi... par
Introduction to GitHub Actions - How to easily automate and integrate with Gi...Introduction to GitHub Actions - How to easily automate and integrate with Gi...
Introduction to GitHub Actions - How to easily automate and integrate with Gi...All Things Open
109 vues35 diapositives
Containers Demystified par
Containers DemystifiedContainers Demystified
Containers DemystifiedAll Things Open
20 vues86 diapositives
Kubernetes Problem-Solving par
Kubernetes Problem-SolvingKubernetes Problem-Solving
Kubernetes Problem-SolvingAll Things Open
122 vues54 diapositives
Using Git to Organize Your Project par
Using Git to Organize Your ProjectUsing Git to Organize Your Project
Using Git to Organize Your ProjectManish Suwal 'Enwil'
4.2K vues56 diapositives

Contenu connexe

Similaire à Introduction to GitHub Actions – How to easily automate and integrate with GitHub

Hybrid and Multi-Cloud Strategies for Kubernetes with GitOps par
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOpsHybrid and Multi-Cloud Strategies for Kubernetes with GitOps
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOpsSonja Schweigert
61 vues37 diapositives
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOps par
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOpsHybrid and Multi-Cloud Strategies for Kubernetes with GitOps
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOpsWeaveworks
245 vues37 diapositives
GitHub Actions 101 par
GitHub Actions 101GitHub Actions 101
GitHub Actions 101Nico Meisenzahl
112 vues19 diapositives
Agile Secure Cloud Application Development Management par
Agile Secure Cloud Application Development ManagementAgile Secure Cloud Application Development Management
Agile Secure Cloud Application Development ManagementAdam Getchell
986 vues63 diapositives
Git and GitHub for Documentation par
Git and GitHub for DocumentationGit and GitHub for Documentation
Git and GitHub for DocumentationAnne Gentle
57.5K vues39 diapositives
Introduction to Git for Network Engineers par
Introduction to Git for Network EngineersIntroduction to Git for Network Engineers
Introduction to Git for Network EngineersJoel W. King
864 vues13 diapositives

Similaire à Introduction to GitHub Actions – How to easily automate and integrate with GitHub(20)

Hybrid and Multi-Cloud Strategies for Kubernetes with GitOps par Sonja Schweigert
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOpsHybrid and Multi-Cloud Strategies for Kubernetes with GitOps
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOps
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOps par Weaveworks
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOpsHybrid and Multi-Cloud Strategies for Kubernetes with GitOps
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOps
Weaveworks245 vues
Agile Secure Cloud Application Development Management par Adam Getchell
Agile Secure Cloud Application Development ManagementAgile Secure Cloud Application Development Management
Agile Secure Cloud Application Development Management
Adam Getchell986 vues
Git and GitHub for Documentation par Anne Gentle
Git and GitHub for DocumentationGit and GitHub for Documentation
Git and GitHub for Documentation
Anne Gentle57.5K vues
Introduction to Git for Network Engineers par Joel W. King
Introduction to Git for Network EngineersIntroduction to Git for Network Engineers
Introduction to Git for Network Engineers
Joel W. King864 vues
Increase the Velocity of Your Software Releases Using GitHub and DeployHub par DevOps.com
Increase the Velocity of Your Software Releases Using GitHub and DeployHubIncrease the Velocity of Your Software Releases Using GitHub and DeployHub
Increase the Velocity of Your Software Releases Using GitHub and DeployHub
DevOps.com237 vues
給 RD 的 Kubernetes 初體驗 (gcpug 2019-06 version) par William Yeh
給 RD 的 Kubernetes 初體驗 (gcpug 2019-06 version)給 RD 的 Kubernetes 初體驗 (gcpug 2019-06 version)
給 RD 的 Kubernetes 初體驗 (gcpug 2019-06 version)
William Yeh2K vues
Using GitHub Actions to Deploy your Workloads to Azure par Kasun Kodagoda
Using GitHub Actions to Deploy your Workloads to AzureUsing GitHub Actions to Deploy your Workloads to Azure
Using GitHub Actions to Deploy your Workloads to Azure
Kasun Kodagoda258 vues
Containers in depth – Understanding how containers work to better work with c... par All Things Open
Containers in depth – Understanding how containers work to better work with c...Containers in depth – Understanding how containers work to better work with c...
Containers in depth – Understanding how containers work to better work with c...
All Things Open81 vues
Continuous Lifecycle London 2018 Event Keynote par Weaveworks
Continuous Lifecycle London 2018 Event KeynoteContinuous Lifecycle London 2018 Event Keynote
Continuous Lifecycle London 2018 Event Keynote
Weaveworks4.1K vues
Effiziente CI/CD-Pipelines – mit den richtigen Tools klappt das par Nico Meisenzahl
Effiziente CI/CD-Pipelines – mit den richtigen Tools klappt dasEffiziente CI/CD-Pipelines – mit den richtigen Tools klappt das
Effiziente CI/CD-Pipelines – mit den richtigen Tools klappt das
Nico Meisenzahl48 vues
Continuous Integration with Cloud Foundry Concourse and Docker on OpenPOWER par Indrajit Poddar
Continuous Integration with Cloud Foundry Concourse and Docker on OpenPOWERContinuous Integration with Cloud Foundry Concourse and Docker on OpenPOWER
Continuous Integration with Cloud Foundry Concourse and Docker on OpenPOWER
Indrajit Poddar1K vues
GitHub Actions - using Free Oracle Cloud Infrastructure (OCI) par Phil Wilkins
GitHub Actions - using Free Oracle Cloud Infrastructure (OCI)GitHub Actions - using Free Oracle Cloud Infrastructure (OCI)
GitHub Actions - using Free Oracle Cloud Infrastructure (OCI)
Phil Wilkins2.2K vues
Windows containers on Kubernetes par Craig Peters
Windows containers on KubernetesWindows containers on Kubernetes
Windows containers on Kubernetes
Craig Peters133 vues
DevOpsCon London: How containerized Pipelines can boost your CI/CD par Nico Meisenzahl
DevOpsCon London: How containerized Pipelines can boost your CI/CDDevOpsCon London: How containerized Pipelines can boost your CI/CD
DevOpsCon London: How containerized Pipelines can boost your CI/CD
Nico Meisenzahl221 vues
GitOps: Git come unica fonte di verità per applicazioni e infrastruttura par sparkfabrik
GitOps: Git come unica fonte di verità per applicazioni e infrastrutturaGitOps: Git come unica fonte di verità per applicazioni e infrastruttura
GitOps: Git come unica fonte di verità per applicazioni e infrastruttura
sparkfabrik533 vues
Virtual GitLab Meetup: How Containerized Pipelines and Kubernetes Can Boost Y... par Nico Meisenzahl
Virtual GitLab Meetup: How Containerized Pipelines and Kubernetes Can Boost Y...Virtual GitLab Meetup: How Containerized Pipelines and Kubernetes Can Boost Y...
Virtual GitLab Meetup: How Containerized Pipelines and Kubernetes Can Boost Y...
Nico Meisenzahl206 vues

Plus de All Things Open

Open Source and Public Policy par
Open Source and Public PolicyOpen Source and Public Policy
Open Source and Public PolicyAll Things Open
13 vues14 diapositives
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak... par
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...All Things Open
7 vues38 diapositives
The State of Passwordless Auth on the Web - Phil Nash par
The State of Passwordless Auth on the Web - Phil NashThe State of Passwordless Auth on the Web - Phil Nash
The State of Passwordless Auth on the Web - Phil NashAll Things Open
7 vues61 diapositives
Total ReDoS: The dangers of regex in JavaScript par
Total ReDoS: The dangers of regex in JavaScriptTotal ReDoS: The dangers of regex in JavaScript
Total ReDoS: The dangers of regex in JavaScriptAll Things Open
5 vues42 diapositives
What Does Real World Mass Adoption of Decentralized Tech Look Like? par
What Does Real World Mass Adoption of Decentralized Tech Look Like?What Does Real World Mass Adoption of Decentralized Tech Look Like?
What Does Real World Mass Adoption of Decentralized Tech Look Like?All Things Open
11 vues28 diapositives
How to Write & Deploy a Smart Contract par
How to Write & Deploy a Smart ContractHow to Write & Deploy a Smart Contract
How to Write & Deploy a Smart ContractAll Things Open
9 vues12 diapositives

Plus de All Things Open(20)

Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak... par All Things Open
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
The State of Passwordless Auth on the Web - Phil Nash par All Things Open
The State of Passwordless Auth on the Web - Phil NashThe State of Passwordless Auth on the Web - Phil Nash
The State of Passwordless Auth on the Web - Phil Nash
Total ReDoS: The dangers of regex in JavaScript par All Things Open
Total ReDoS: The dangers of regex in JavaScriptTotal ReDoS: The dangers of regex in JavaScript
Total ReDoS: The dangers of regex in JavaScript
What Does Real World Mass Adoption of Decentralized Tech Look Like? par All Things Open
What Does Real World Mass Adoption of Decentralized Tech Look Like?What Does Real World Mass Adoption of Decentralized Tech Look Like?
What Does Real World Mass Adoption of Decentralized Tech Look Like?
All Things Open11 vues
Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow par All Things Open
 Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow
Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow
Supercharging tutorials with WebAssembly par All Things Open
Supercharging tutorials with WebAssemblySupercharging tutorials with WebAssembly
Supercharging tutorials with WebAssembly
All Things Open15 vues
Configuration Security as a Game of Pursuit Intercept par All Things Open
Configuration Security as a Game of Pursuit InterceptConfiguration Security as a Game of Pursuit Intercept
Configuration Security as a Game of Pursuit Intercept
Build Developer Experience Teams for Open Source par All Things Open
Build Developer Experience Teams for Open SourceBuild Developer Experience Teams for Open Source
Build Developer Experience Teams for Open Source
Fortifying the Future: Tackling Security Challenges in AI/ML Applications par All Things Open
Fortifying the Future: Tackling Security Challenges in AI/ML ApplicationsFortifying the Future: Tackling Security Challenges in AI/ML Applications
Fortifying the Future: Tackling Security Challenges in AI/ML Applications
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov... par All Things Open
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
All Things Open12 vues
Building AlmaLinux OS without RHEL sources code par All Things Open
Building AlmaLinux OS without RHEL sources codeBuilding AlmaLinux OS without RHEL sources code
Building AlmaLinux OS without RHEL sources code
All Things Open11 vues
Open Source evaluation: A comprehensive guide on what you are using par All Things Open
Open Source evaluation: A comprehensive guide on what you are usingOpen Source evaluation: A comprehensive guide on what you are using
Open Source evaluation: A comprehensive guide on what you are using
All Things Open21 vues
Know Your Data: The stats behind your alerts par All Things Open
Know Your Data: The stats behind your alertsKnow Your Data: The stats behind your alerts
Know Your Data: The stats behind your alerts
The Path to Real-time Data Integration with Open Source par All Things Open
The Path to Real-time Data Integration with Open SourceThe Path to Real-time Data Integration with Open Source
The Path to Real-time Data Integration with Open Source
All Things Open11 vues

Dernier

Tunable Laser (1).pptx par
Tunable Laser (1).pptxTunable Laser (1).pptx
Tunable Laser (1).pptxHajira Mahmood
24 vues37 diapositives
Network Source of Truth and Infrastructure as Code revisited par
Network Source of Truth and Infrastructure as Code revisitedNetwork Source of Truth and Infrastructure as Code revisited
Network Source of Truth and Infrastructure as Code revisitedNetwork Automation Forum
26 vues45 diapositives
AMAZON PRODUCT RESEARCH.pdf par
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdfJerikkLaureta
26 vues13 diapositives
PRODUCT PRESENTATION.pptx par
PRODUCT PRESENTATION.pptxPRODUCT PRESENTATION.pptx
PRODUCT PRESENTATION.pptxangelicacueva6
14 vues1 diapositive
SUPPLIER SOURCING.pptx par
SUPPLIER SOURCING.pptxSUPPLIER SOURCING.pptx
SUPPLIER SOURCING.pptxangelicacueva6
15 vues1 diapositive
The details of description: Techniques, tips, and tangents on alternative tex... par
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...BookNet Canada
127 vues24 diapositives

Dernier(20)

The details of description: Techniques, tips, and tangents on alternative tex... par BookNet Canada
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada127 vues
Unit 1_Lecture 2_Physical Design of IoT.pdf par StephenTec
Unit 1_Lecture 2_Physical Design of IoT.pdfUnit 1_Lecture 2_Physical Design of IoT.pdf
Unit 1_Lecture 2_Physical Design of IoT.pdf
StephenTec12 vues
STPI OctaNE CoE Brochure.pdf par madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb14 vues
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors par sugiuralab
TouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective SensorsTouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective Sensors
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors
sugiuralab19 vues
Case Study Copenhagen Energy and Business Central.pdf par Aitana
Case Study Copenhagen Energy and Business Central.pdfCase Study Copenhagen Energy and Business Central.pdf
Case Study Copenhagen Energy and Business Central.pdf
Aitana16 vues
Transcript: The Details of Description Techniques tips and tangents on altern... par BookNet Canada
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...
BookNet Canada136 vues
Empathic Computing: Delivering the Potential of the Metaverse par Mark Billinghurst
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
PharoJS - Zürich Smalltalk Group Meetup November 2023 par Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi127 vues

Introduction to GitHub Actions – How to easily automate and integrate with GitHub

  • 1. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 2 © 2022 Brent C. Laster & Tech Skills Transformations & Brent Laster Introduction to GitHub Actions
  • 2. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 3 © 2022 Brent C. Laster & About me • R&D Director, DevOps • Global trainer – training (Git, Jenkins, Gradle, CI/CD, pipelines, Kubernetes, Helm, ArgoCD, operators) • Author - § OpenSource.com § Professional Git book § Jenkins 2 – Up and Running book § Mini-books on O'Reilly § GitHub Actions book (coming in 2023 - early preview on O'Reilly) techskillstransformations.com getskillsnow.com https://www.linkedin.com/in/brentlaster @BrentCLaster GitHub: brentlaster
  • 3. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 4 © 2022 Brent C. Laster & Book – Professional Git • Extensive Git reference, explanations, and examples • First part for non-technical • Beginner and advanced reference • Hands-on labs
  • 4. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 5 © 2022 Brent C. Laster & Jenkins 2 Book • Jenkins 2 – Up and Running • “It’s an ideal book for those who are new to CI/CD, as well as those who have been using Jenkins for many years. This book will help you discover and rediscover Jenkins.” By Kohsuke Kawaguchi, Creator of Jenkins
  • 5. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 6 © 2022 Brent C. Laster & Learning GitHub Actions - Early Release • Early release - Chapters 1 & 2 on learning.oreilly.com
  • 6. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 7 © 2022 Brent C. Laster & ATO 2022 Session: Cloud-native CI/CD in Kubernetes with Tekton Tekton is a newer entry in the CI/CD tooling space that allows you to implement CI/CD pipelines through custom Kubernetes objects. Because of that, you can utilize the same Kubernetes knowledge you already have without learning another application and take advantage of your existing Kubernetes infrastructure and features such as scaling that are built in. Join author and trainer and DevOps Director Brent Laster to learn how to easily and quickly get up to speed with Tekton and the supporting pieces around it including its dashboard and CLI.
  • 7. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 8 © 2022 Brent C. Laster & O’Reilly Training
  • 8. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 9 © 2022 Brent C. Laster & NFJS Training
  • 9. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 10 © 2022 Brent C. Laster & What are GitHub Actions? • Way to create custom, automated workflows in GitHub • Executed based on repository operations • Building blocks - can be combined & shared • Used for usual SDLC tasks • Can be used for CI/CD as alternatives to other apps
  • 10. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 11 © 2022 Brent C. Laster & Example use cases (starter workflows)
  • 11. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 12 © 2022 Brent C. Laster & What's interesting about it? • Direct integration with GitHub
  • 12. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 13 © 2022 Brent C. Laster & What else is interesting about it? • Lots of events can trigger an action workflow - automate practically anything! on: project on: watch on: repository_dispatch on: delete on: check_run on: page_build on: scheduled on: pull_request on: public on: pull_request_review_comment on: pull_push on: fork https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
  • 13. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 14 © 2022 Brent C. Laster & Types of triggers for events • single event - on: push • list of events - on: [push, pull_request] • specify activity types or configuration - on: push: branches: - main • scheduled events - on: scheduled: - cron: '30 5,15 * * *' • manual events - on: workflow-dispatch on: repository-dispatch [opened, deleted] • workflow reuse events - on: workflow-call (can be called from another workflow) • webhook events - on: issue_comment on: pull_request
  • 14. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 15 © 2022 Brent C. Laster & How Actions work (events) • Events occur § Example: pull request triggers build for validation § Example: push for commit • Repository Dispatch Events § Endpoint that can be used to trigger webhook event § Can be used for activity that is not in GitHub § Can trigger a GitHub Actions workflow or GitHub App webhook • ref https://docs.github.com /en/rest/reference/repo s#create-a-repository- dispatch-event Event
  • 15. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 16 © 2022 Brent C. Laster & How Actions work (workflows) • Events trigger workflows workflow Event § Procedure to run automatically § Added to your repository § Composed of one+ jobs § Can be triggered/scheduled by event § Useful for doing CI/CD actions such as building, testing, packaging, etc.
  • 16. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 17 © 2022 Brent C. Laster & How actions work (jobs, steps, actions, shell cmds) Workflows contain jobs § Set of steps § Workflow with multiple jobs runs them in parallel Jobs contain steps § A task that can execute commands in a job § Can be either » action » shell command workflow Job 1 Job 2 Event Step 1 Step 1 Step 2 action or shell cmd action § Independent commands § Based off repository in GitHub § Used in steps to form a job § Smallest unit in a workflow § Can be created or pulled in from the community § Only usable if included as a step action or shell cmd action or shell cmd
  • 17. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 18 © 2022 Brent C. Laster & How Actions work (runner) Runner • A server with GitHub Actions runner app on it • Can use runner provided by/hosted via GitHub or use your own • Runner listens for available jobs • Steps in a job execute on the same runner workflow Job 1 Job 2 Event Step 1 Step 1 Step 2 Runner 1 action or cmd runs Runner 2 action or cmd runs logs results logs results action or shell cmd action or shell cmd action or shell cmd
  • 18. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 19 © 2022 Brent C. Laster & How actions work GitHub Repository .github workflows workflow1.yml Job 1 Step 1 Step 2 Job 2 Step 1 workflow2.yml Job 1 Step 1 Job 2 Step 1 Step 2 Runner 1 Runner 2 Event • Resides in .github/workflows • Can have multiple workflows action or shell cmd action or shell cmd action or shell cmd action or shell cmd action or shell cmd action or shell cmd action or cmd runs logs results action or cmd runs logs results
  • 19. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 20 © 2022 Brent C. Laster & GitHub-hosted vs Self-hosted Runners GitHub-hosted Self-hosted Definition Hosted by GitHub Any system/configuration you want to use Prereqs Running GitHub actions runner application GitHub actions self-hosted runner application Platforms Windows, Linux, MacOS Any that can be made to work Advantages Quicker and simpler Highly configurable Management/Ownership GitHub As defined Clean instance For every job execution Optional Cost Free minutes on GitHub plan with cost for overages Free to use with actions, but owner is responsible for any other cost Automatic updates For OS, installed packages, tools, and hosted runner application Only for self-hosted runner application Implementation Virtual Virtual or physical
  • 20. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 21 © 2022 Brent C. Laster & GitHub Actions Runners • Virtual environments for GitHub actions hosted runners • New VM for each job run • VM images of Microsoft-hosted agents used for Azure Pipelines • Updated periodically by GitHub
  • 21. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 22 © 2022 Brent C. Laster & Self-hosted Runners • Useful when you need more configurability and control • Allows you to choose and customize configuration, system resources, available software, etc. • Can be physical systems, VMs, containers, on- prem or cloud • Runner system connects to GitHub via GitHub Actions self-hosted runner • Automatically kicked off of GitHub if no connection to GitHub Actions after 30 days • Recommended to use only with private repos § Forks of repos could run dangerous code on self- hosted runner machine (via PR that executes code in workflow)
  • 22. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 23 © 2022 Brent C. Laster & GitHub Actions Storage - Artifacts • Actions allow you to persist data after job has completed - as artifacts • Artifact - file or collection of files produced during workflow run § build and test output § log files § binary files • Artifacts are uploaded during workflow run § can be shared between jobs in same workflow § visible in the UI • Default retention period is 90 days
  • 23. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 24 © 2022 Brent C. Laster & How much does it cost? (part 1) • Free for public repos and/or self-hosted runners • For private repos, each GitHub account gets designated amount of free minutes and storage § above that, usage is controlled by spending limits § minutes reset every month, but not storage Product Storage Minutes (per month) GitHub Free 500 MB 2,000 GitHub Pro 1 GB 3,000 GitHub Free for organizations 500 MB 2,000 GitHub Team 2 GB 3,000 GitHub Enterprise Cloud 50 GB 50,000
  • 24. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 25 © 2022 Brent C. Laster & How much does it cost? (part 2) • Total storage is Actions artifacts and GitHub Packages § GitHub Packages = platform for hosting and managing packages, such as containers or dependencies • Storage usage is calculated for each month based on hourly usage during the month • Per-minute rates • If jobs run on Windows or macOS on runners hosted by GitHub, multiplier comes into play Operating system Minute multiplier Linux 1 macOS 10 Windows 2 Operating system Per-minute rate (USD) Linux $0.008 macOS $0.08 Windows $0.016
  • 25. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 26 © 2022 Brent C. Laster & Integration with GitHub Interface
  • 26. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 27 © 2022 Brent C. Laster & Viewing Logs
  • 27. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 28 © 2022 Brent C. Laster & Viewing the Workflow Run history
  • 28. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 29 © 2022 Brent C. Laster & Filtering workflows • Enter text in search bar • Click on "x" at end to clear • Click on category in "workflow run results" bar • Select from the list
  • 29. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 30 © 2022 Brent C. Laster & Viewing a Specific Workflow Run
  • 30. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 31 © 2022 Brent C. Laster & Job Graph
  • 31. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 32 © 2022 Brent C. Laster & Drilling into logs
  • 32. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 33 © 2022 Brent C. Laster & Editing Workflows
  • 33. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 34 © 2022 Brent C. Laster & Editing with VSCode • Hit "." when in file
  • 34. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 35 © 2022 Brent C. Laster & Updating workflows with Pull Requests #1
  • 35. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 36 © 2022 Brent C. Laster & Running your workflow manually • Add a "workflow dispatch event" trigger • Merge changes • Afterwards will have "Run workflow" button in workflow list
  • 36. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 37 © 2022 Brent C. Laster & Public Actions
  • 37. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 38 © 2022 Brent C. Laster & Searching for a Public Action
  • 38. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 39 © 2022 Brent C. Laster & Actions use Workflows
  • 39. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 40 © 2022 Brent C. Laster & Action Metadata File • action.yml or action.yaml • defines inputs, outputs, runtime env, config, branding • must be present to have an action
  • 40. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 41 © 2022 Brent C. Laster & Custom Actions • Can be created by you • Can result from customizing community actions • Can be put on Marketplace and shared • repository must be public • Can integrate with any public API • Can run directly on a machine or in Docker container • Can define inputs, outputs, and environment variables • Require metadata file • defines inputs, outputs, and entrypoint • must be named either action.yaml or action.yml • Should be tagged with a label and then pushed to GitHub • To use: • In file in .github/workflows/main.yml • In steps • "uses: <github path to action>@<label> $ <create GitHub repo> $ <clone repo> $ <create files> $ git add action.yml <other files> $ git commit -m "action files" $ git tag -a -m "first release of action" v1 $ git push --follow-tags on: [push] jobs: example_job: runs on: ubuntu-latest name: An example job steps: - name: Example step id: example_step uses: <repo name>/<action name>@<tag> ... .github/workflows/example.yml
  • 41. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 42 © 2022 Brent C. Laster & Custom Action Types • Docker • Packages env with actions code • Env can include specific OS versions, config, tools, etc. • Well suited for specific env needs • Runs only on Linux runners with Docker installed • Slower due to cost of building and retrieving container • GitHub builds image from Dockerfile and runs comands in a new container based on image • Javascript • Run directly on runner for any of macOS, Linux, or Windows • Separates action from env • Fast than Docker • Needs to be pure JavaScript (no other binaries) • Can use binaries already on runner • Composite • Combines multiple workflow steps in one action Runner FROM <base> .... COPY <entry script> ENTRYPOINT <script> Dockerfile ... runs: using: 'docker' image: 'Dockerfile' args: .... action.yml + + Runner + + ... runs: using: 'node12' main: 'index.js' action.yml npm install @actions/core npm install @actions/github const core = require('@actions/core'); const github = require('@actions/github); try{ ... } catch (error) { ... } index.js Runner ... runs: using: 'composite' - run: echo ... - run: ${{ github.action.path }}/shell-script.sh action.yml + echo ... ... shell-script.sh
  • 42. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 43 © 2022 Brent C. Laster & Workflow commands • Used to communicate with the runner machine to § Set environment variables § Set output values used by other actions § Add debug messages to logs • Typically use "echo" command with certain format • Also can be used to execute some commands in Actions Toolkit
  • 43. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 44 © 2022 Brent C. Laster & Actions Toolkit • Provides packages for more easily creating/working with actions • Functions in packages can be run in code as in core.setOutput('SELECTED_COLOR ', 'red'); or (in many cases) • run as workflow commands - name: Set selected color run: echo '::set-output name=SELECTED_COLOR::green'
  • 44. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 45 © 2022 Brent C. Laster & Actions Toolkit packages • Collections of related functions • Can be imported into code for actions
  • 45. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 46 © 2022 Brent C. Laster & Monitoring and Troubleshooting • Use "default" information § Visualization graph of a workflow § Workflow run history § Workflow logs § Dump out the runner context § Enable debug logging » can use core.debug or "echo "::debug:: <message>" » must be enabled via setting up secrets » ACTIONS_RUNNER_DEBUG » ACTIONS_STEP_DEBUG
  • 46. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 47 © 2022 Brent C. Laster & Enabling/Creating Secrets for Actions • Create in same repo, so same permissions needed 1 2 3
  • 47. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 48 © 2022 Brent C. Laster & Defining Secrets for Actions • Provide secret name • Provide value • Add secret
  • 48. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 49 © 2022 Brent C. Laster & GitHub Personal Access Token • Provides specific accesses • Replaces passwords • Can be done through https://github.com/settings/tokens • Or can be setup via Settings->Profile->Developer Settings->Personal Access Tokens • Generate new token and save it
  • 49. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 50 © 2022 Brent C. Laster & Workflows invoking GitHub • Workflows can invoke GitHub or other functionality via techniques such as curl
  • 50. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 51 © 2022 Brent C. Laster & Chaining Workflows Together • Can be done via GitHub API calls • Requires API Token saved as a secret • One workflow then invokes the other via API call create-issue-on-failure: runs-on: ubuntu-latest needs: [test-run, count-args] if: always() && failure() steps: - name: invoke workflow to create issue run: > curl -X POST -H "authorization: Bearer ${{ secrets.WORKFLOW_USE }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${{ github.repository }}/actions/workflows/create-failure-issue.yml/dispatches" -d '{"ref":"main", "inputs": {"title":"Automated workflow failure issue for commit ${{ github.sha }}", "body":"This issue was automatically created by the GitHub Action workflow ** ${{ github.workflow }} **"} }'
  • 51. techupskills.com | techskillstransformations.com © 2021 Brent C. Laster & @techupskills 52 © 2022 Brent C. Laster & That’s all - thanks! techskillstransformations.com getskillsnow.com