SlideShare a Scribd company logo
Speaker: Alexey Golub @Tyrrrz
GitHub Actions
…in action!
/whois ${speaker}
Speaker: Alexey Golub @Tyrrrz
• Open-source developer ✨
• Conference speaker & blogger 🌐️
• C#, F#, JavaScript 💻
• Cloud & web ☁️
• Automation & DevOps ⚙️
GitHub Actions at a glance
• Globally available since November 13, 2019
• Based on Azure Pipelines
• Native integration with GitHub API
• YAML-based configuration
• Modular architecture & community-driven
• Runners on Windows, Linux, macOS, or self-hosted
• Available with Free, Pro, Team, Enterprise Cloud, One
Speaker: Alexey Golub @Tyrrrz
Product Storage Minutes
(monthly)
GitHub Free 500 MB 2,000
GitHub Pro 1 GB 3,000
GitHub Team 2 GB 10,000
GitHub Enterprise Cloud 50 GB 50,000
Speaker: Alexey Golub @Tyrrrz
Free! ✨
Operating
system
Minute
multiplier
Windows 2
Linux 1
macOS 10
Private repositoriesPublic repositories
Operating
system
Per-minute
rate
Windows $0.016
Linux $0.008
macOS $0.080
GitHub Actions
=
IFTTT for GitHub repositories
Speaker: Alexey Golub @Tyrrrz
Speaker: Alexey Golub @Tyrrrz
Add positional arguments (fixes #26)
Use ValueTask in ICommand
Include shared props file
Add support for autocompletion
How can I implement a custom converter?
Add required options to help text
Trigger CI build
Label issue
Tag reviewers
Released v1.7.2 Post a message in Slack
EVENT
EVENT
EVENT
EVENT
Speaker: Alexey Golub @Tyrrrz
Workflow
Trigger
Job
Step
Job
. . .
Job
Step
. . .
Step
PULL
REQUEST
Continuous integration
Build, test, coverage
Scripts, actions
Speaker: Alexey Golub @Tyrrrz
Speaker: Alexey Golub @Tyrrrz
~/.github/workflows/CI.yml
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.100
- name: Build & test
run: dotnet test --configuration Release
- name: Build & publish
run: dotnet publish LightBulb/ -o LightBulb/bin/Publish/ --configuration Release
- name: Upload build artifacts
uses: actions/upload-artifact@master
with:
name: LightBulb
path: LightBulb/bin/Publish/
Trigger on new commits and pull requests
Clone repository and checkout HEAD
(commit hash is passed as env var)
Install .NET Core v3.1.100 Run custom shell scripts
Upload specified directory as
a ZIP artifact
Speaker: Alexey Golub @Tyrrrz
Speaker: Alexey Golub @Tyrrrz
Speaker: Alexey Golub @Tyrrrz
Triggers
• GitHub API events ⚡
push, pull_request, issues, release, and 20 others
• Schedule 🕒
Cron syntax, e.g.: */15 * * * *
• Manual 🌐️
POST to /repos/:owner/:repo/dispatches
Speaker: Alexey Golub @Tyrrrz
Speaker: Alexey Golub @Tyrrrz
# Trigger on push events on s
pecific branches
on:
push:
branches:
- 'master'
- 'release/*'
# Trigger every midnight UTC
on:
schedule:
- cron: '0 0 * * *'
# Trigger on manual dispatch
on: repository_dispatch
# Trigger when an issue is opened o
r labeled
on:
issues:
types: [opened, labeled]
Referencing actions
• By GitHub repository 📚
{owner}/{repo}@{ref} jessfraz/branch-cleanup-action@master
{owner}/{repo}/{path}@{ref} johndoe/my-actions/push-image@v1
• By file path 📁
./path/to/dir ./.github/actions/my-action
• By Docker image 🐳
docker://{image}:{tag} docker://hello-world:latest
Speaker: Alexey Golub @Tyrrrz
Advanced configurations
Speaker: Alexey Golub @Tyrrrz
Matrices
Speaker: Alexey Golub @Tyrrrz
name: Matrix Reloaded
on: [push]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 4
matrix:
os: [ubuntu-16.04, ubuntu-18.04]
node-ver: [6, 8, 10]
steps:
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-ver }}
Reference variables from the matrix
Ubuntu-16.04 Ubuntu-18.04
Node v6 Node v6
Node v8 Node v8
Node v10 Node v10
Docker containers
Speaker: Alexey Golub @Tyrrrz
jobs:
build:
services:
redis:
image: redis
ports:
- 6379/tcp
options: --entrypoint redis-server
steps:
env:
REDIS_HOST: localhost
REDIS_PORT: ${{ job.services.redis.ports[6379] }}
Image from the Docker registry
Bind port 6379 in container to a random port on host
Exposed port is resolved dynamically
Custom arguments passed to docker create
Secrets
Speaker: Alexey Golub @Tyrrrz
steps:
# ...
- name: Collect coverage report
run: |
choco install codecov --no-progress
codecov -f LtGt.Tests/bin/Release/Coverage.xml -t ${{secrets.CODECOV_TOKEN}}
Secret variable
Speaker: Alexey Golub @Tyrrrz
Speaker: Alexey Golub @Tyrrrz
Secrets are automatically obfuscated in logs
Action to action I/O
Speaker: Alexey Golub @Tyrrrz
- name: Create release
id: create_release
uses: actions/create-release@v1
- name: Upload release asset
uses: actions/upload-release-asset@v1.0.1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
Actions can be referenced by their ID
Resolved from the outputs of another action
Conditionals
Speaker: Alexey Golub @Tyrrrz
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
run: dotnet nuget push src/**.nupkg -k ${{secrets.NUGET_TOKEN}}
Conditional expression
Things we can do with GitHub Actions
• Run tests on every commit
• Publish Docker image when a tag is pushed
• Label an issue by content when it’s created
• Run nightly E2E tests
• Automatically close stale issues every week
• Invite new contributors to sign the CLA when a PR is opened
• Automatically format code on push
• …
Speaker: Alexey Golub @Tyrrrz
Examples of actions you can
use in your workflows
Speaker: Alexey Golub @Tyrrrz
actions/github-script
Speaker: Alexey Golub @Tyrrrz
- uses: actions/github-script@0.4.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '👋 Thanks for reporting!'
})
Runs inline JS code that
uses the GitHub API
actions/stale
Speaker: Alexey Golub @Tyrrrz
- uses: actions/stale@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: ’Issue closed due to inactivity.'
stale-pr-message: ’PR closed due to inactivity.’
days-before-stale: 30
days-before-close: 5
Closes stale issues
and PRs
sonarsource/sonarcloud-github-action
Speaker: Alexey Golub @Tyrrrz
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Sends code to
SonarCloud to scan for
issues
vsoch/pull-request-action
Speaker: Alexey Golub @Tyrrrz
- name: pull-request-action
uses: vsoch/pull-request-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_PREFIX: "features/"
PULL_REQUEST_BRANCH: "master"
Automatically creates a
pull request when
publishing a new
branch
Discovering actions
Speaker: Alexey Golub @Tyrrrz
Can’t find an action you
need? Make your own!
Speaker: Alexey Golub @Tyrrrz
JavaScript-based actions
• Supported by all runners
• Can only use JavaScript
• Requires a single self-contained .js file as the entry point
• Node modules @actions/core & @actions/github
Speaker: Alexey Golub @Tyrrrz
action.yml index.js
+
Speaker: Alexey Golub @Tyrrrz
name: 'Hello World'
description: 'Greet someone and record time'
inputs:
who-to-greet:
description: 'Who to greet'
required: true
default: 'World'
outputs:
time:
description: 'The time we greeted you'
runs:
using: 'node12'
main: 'index.js'
~/action.yml
Metadata associated with an action
Inputs & outputs
Entry point
Speaker: Alexey Golub @Tyrrrz
const core = require('@actions/core');
const github = require('@actions/github');
try {
// `who-to-greet` input defined in action metadata file
const nameToGreet = core.getInput('who-to-greet');
console.log(`Hello ${nameToGreet}!`);
const time = (new Date()).toTimeString();
core.setOutput("time", time);
// Get the JSON webhook payload for the event that triggered the workflow
const payload = JSON.stringify(github.context.payload, undefined, 2)
console.log(`The event payload: ${payload}`);
} catch (error) {
core.setFailed(error.message);
}
~/index.js
Docker-based actions
• Supported only by Linux-based runners (for now)
• Can use any language or runtime
• Typically runs slower
Speaker: Alexey Golub @Tyrrrz
action.yml Dockerfile
+
Speaker: Alexey Golub @Tyrrrz
name: 'Hello World'
description: 'Greet someone and record time'
inputs:
who-to-greet:
description: 'Who to greet'
required: true
default: 'World'
outputs:
time:
description: 'The time we greeted you'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.who-to-greet }}
~/action.yml
FROM ubuntu:18.04
COPY entrypoint.sh ./
ENTRYPOINT ["/entrypoint.sh"]
~/Dockerfile
#!/bin/sh -l
echo "Hello $1"
time=$(date)
echo ::set-output name=time::$time
~/entrypoint.sh
Speaker: Alexey Golub @Tyrrrz
Special commands
• ::set-output name=action_fruit::strawberry
• ::set-env name=action_state::yellow
• ::add-path::/path/to/dir
• ::debug file=app.js,line=1::Entered method
• ::warning file=app.js,line=1,col=5::Missing semicolon
• ::error file=app.js,line=10,col=15::Oops
• ::add-mask::Mona The Octocat
Publishing actions to marketplace
Speaker: Alexey Golub @Tyrrrz
Speaker: Alexey Golub @Tyrrrz
Summary
• GitHub Actions is an automation platform (not just CI/CD)
• Can trigger workflows on various events
• Workflows are based on actions which are sourced by the community
• Free for all public repos, pay-as-you-go for private repos
• Easy to set up and configure to your needs
Speaker: Alexey Golub @Tyrrrz
For the curious
• Awesome Actions by Sarah Drasner
https://github.com/sdras/awesome-actions
• GitHub Actions Advent Calendar by Edward Thomson
https://edwardthomson.com/blog/github_actions_advent_calendar.html
• Comprehensive Introduction to GitHub Actions by Tierney Cyren
https://dev.to/bnb/an-unintentionally-comprehensive-introduction-to-
github-actions-ci-blm
• Official documentation
https://help.github.com/en/actions
Speaker: Alexey Golub @Tyrrrz
Thank you!
https://github.com/Tyrrrz
https://twitter.com/Tyrrrz
https://tyrrrz.me

More Related Content

What's hot

Container based CI/CD on GitHub Actions
Container based CI/CD on GitHub ActionsContainer based CI/CD on GitHub Actions
Container based CI/CD on GitHub Actions
Casey Lee
 
CI/CD with Github Actions
CI/CD with Github ActionsCI/CD with Github Actions
CI/CD with Github Actions
Md. Minhazul Haque
 
Continuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CIContinuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CI
David Hahn
 
CI/CD with GitHub Actions
CI/CD with GitHub ActionsCI/CD with GitHub Actions
CI/CD with GitHub Actions
Swaminathan Vetri
 
Using GitLab CI
Using GitLab CIUsing GitLab CI
Using GitLab CI
ColCh
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
GoogleDevelopersStud1
 
Github
GithubGithub
Github
MeetPatel710
 
GitLab for CI/CD process
GitLab for CI/CD processGitLab for CI/CD process
GitLab for CI/CD process
HYS Enterprise
 
Using GitHub Actions to Deploy your Workloads to Azure
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 Kodagoda
 
Gitlab CI/CD
Gitlab CI/CDGitlab CI/CD
Gitlab CI/CD
JEMLI Fathi
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
Nicolás Tourné
 
GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
"FENG "GEORGE"" YU
 
CI with Gitlab & Docker
CI with Gitlab & DockerCI with Gitlab & Docker
CI with Gitlab & Docker
Joerg Henning
 
GitHub Actions with Node.js
GitHub Actions with Node.jsGitHub Actions with Node.js
GitHub Actions with Node.js
Stefan Stölzle
 
CD using ArgoCD(KnolX).pdf
CD using ArgoCD(KnolX).pdfCD using ArgoCD(KnolX).pdf
CD using ArgoCD(KnolX).pdf
Knoldus Inc.
 
Introduction to Github Actions
Introduction to Github ActionsIntroduction to Github Actions
Introduction to Github Actions
Knoldus Inc.
 
Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1
Omar Fathy
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategies
jstack
 
Introducing GitLab (June 2018)
Introducing GitLab (June 2018)Introducing GitLab (June 2018)
Introducing GitLab (June 2018)
Noa Harel
 
Gitlab ci, cncf.sk
Gitlab ci, cncf.skGitlab ci, cncf.sk
Gitlab ci, cncf.sk
Juraj Hantak
 

What's hot (20)

Container based CI/CD on GitHub Actions
Container based CI/CD on GitHub ActionsContainer based CI/CD on GitHub Actions
Container based CI/CD on GitHub Actions
 
CI/CD with Github Actions
CI/CD with Github ActionsCI/CD with Github Actions
CI/CD with Github Actions
 
Continuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CIContinuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CI
 
CI/CD with GitHub Actions
CI/CD with GitHub ActionsCI/CD with GitHub Actions
CI/CD with GitHub Actions
 
Using GitLab CI
Using GitLab CIUsing GitLab CI
Using GitLab CI
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
 
Github
GithubGithub
Github
 
GitLab for CI/CD process
GitLab for CI/CD processGitLab for CI/CD process
GitLab for CI/CD process
 
Using GitHub Actions to Deploy your Workloads to Azure
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
 
Gitlab CI/CD
Gitlab CI/CDGitlab CI/CD
Gitlab CI/CD
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
 
CI with Gitlab & Docker
CI with Gitlab & DockerCI with Gitlab & Docker
CI with Gitlab & Docker
 
GitHub Actions with Node.js
GitHub Actions with Node.jsGitHub Actions with Node.js
GitHub Actions with Node.js
 
CD using ArgoCD(KnolX).pdf
CD using ArgoCD(KnolX).pdfCD using ArgoCD(KnolX).pdf
CD using ArgoCD(KnolX).pdf
 
Introduction to Github Actions
Introduction to Github ActionsIntroduction to Github Actions
Introduction to Github Actions
 
Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategies
 
Introducing GitLab (June 2018)
Introducing GitLab (June 2018)Introducing GitLab (June 2018)
Introducing GitLab (June 2018)
 
Gitlab ci, cncf.sk
Gitlab ci, cncf.skGitlab ci, cncf.sk
Gitlab ci, cncf.sk
 

Similar to GitHub Actions in action

DevOps Fest 2020. Alexey Golub. GitHub Actions in action
DevOps Fest 2020. Alexey Golub. GitHub Actions in actionDevOps Fest 2020. Alexey Golub. GitHub Actions in action
DevOps Fest 2020. Alexey Golub. GitHub Actions in action
DevOps_Fest
 
Alexey Golub - Dependency absolution (application as a pipeline) | Svitla Sma...
Alexey Golub - Dependency absolution (application as a pipeline) | Svitla Sma...Alexey Golub - Dependency absolution (application as a pipeline) | Svitla Sma...
Alexey Golub - Dependency absolution (application as a pipeline) | Svitla Sma...
Oleksii Holub
 
DWX 2022 - DevSecOps mit GitHub
DWX 2022 - DevSecOps mit GitHubDWX 2022 - DevSecOps mit GitHub
DWX 2022 - DevSecOps mit GitHub
Marc Müller
 
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...
Introduction to GitHub Actions - How to easily automate and integrate with Gi...
All Things Open
 
SydJS.com
SydJS.comSydJS.com
SydJS.com
Lachlan Hardy
 
How to Use Your Own Private Registry
How to Use Your Own Private RegistryHow to Use Your Own Private Registry
How to Use Your Own Private Registry
Docker, Inc.
 
Deploying to DigitalOcean With GitHub Actions
Deploying to DigitalOcean With GitHub ActionsDeploying to DigitalOcean With GitHub Actions
Deploying to DigitalOcean With GitHub Actions
DigitalOcean
 
Docker worshop @Twitter - How to use your own private registry
Docker worshop @Twitter - How to use your own private registryDocker worshop @Twitter - How to use your own private registry
Docker worshop @Twitter - How to use your own private registry
dotCloud
 
Gojko Adzic Cucumber
Gojko Adzic CucumberGojko Adzic Cucumber
Gojko Adzic Cucumber
Skills Matter
 
Introduzione a GitHub Actions (beta)
Introduzione a GitHub Actions (beta)Introduzione a GitHub Actions (beta)
Introduzione a GitHub Actions (beta)
Giulio Vian
 
JUGUtrecht2023 - GithubActions
JUGUtrecht2023 - GithubActionsJUGUtrecht2023 - GithubActions
JUGUtrecht2023 - GithubActions
Ixchel Ruiz
 
Make an Instant Website with Webhooks
Make an Instant Website with WebhooksMake an Instant Website with Webhooks
Make an Instant Website with Webhooks
Anne Gentle
 
Knative build for open whisk runtimes phase 1 - 2018-02-20
Knative build for open whisk runtimes   phase 1 - 2018-02-20Knative build for open whisk runtimes   phase 1 - 2018-02-20
Knative build for open whisk runtimes phase 1 - 2018-02-20
Matt Rutkowski
 
Gitlab and Lingvokot
Gitlab and LingvokotGitlab and Lingvokot
Gitlab and Lingvokot
Lingvokot
 
Jenkins Pipelines
Jenkins PipelinesJenkins Pipelines
Jenkins Pipelines
Steffen Gebert
 
Introduction to Tekton
Introduction to TektonIntroduction to Tekton
Introduction to Tekton
Victor Iglesias
 
Using a Private Git Server for Packaging Software
Using a Private Git Server for Packaging SoftwareUsing a Private Git Server for Packaging Software
Using a Private Git Server for Packaging Software
Chris Jean
 
OSCONF - April 2021 - Run GitHub Actions Locally with nektos/act and Docker
OSCONF - April 2021 - Run GitHub Actions Locally with nektos/act and DockerOSCONF - April 2021 - Run GitHub Actions Locally with nektos/act and Docker
OSCONF - April 2021 - Run GitHub Actions Locally with nektos/act and Docker
Gaurav Gahlot
 
Introduction to Github action Presentation
Introduction to Github action PresentationIntroduction to Github action Presentation
Introduction to Github action Presentation
Knoldus Inc.
 
Fullstack workshop
Fullstack workshopFullstack workshop
Fullstack workshop
Assaf Gannon
 

Similar to GitHub Actions in action (20)

DevOps Fest 2020. Alexey Golub. GitHub Actions in action
DevOps Fest 2020. Alexey Golub. GitHub Actions in actionDevOps Fest 2020. Alexey Golub. GitHub Actions in action
DevOps Fest 2020. Alexey Golub. GitHub Actions in action
 
Alexey Golub - Dependency absolution (application as a pipeline) | Svitla Sma...
Alexey Golub - Dependency absolution (application as a pipeline) | Svitla Sma...Alexey Golub - Dependency absolution (application as a pipeline) | Svitla Sma...
Alexey Golub - Dependency absolution (application as a pipeline) | Svitla Sma...
 
DWX 2022 - DevSecOps mit GitHub
DWX 2022 - DevSecOps mit GitHubDWX 2022 - DevSecOps mit GitHub
DWX 2022 - DevSecOps mit GitHub
 
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...
Introduction to GitHub Actions - How to easily automate and integrate with Gi...
 
SydJS.com
SydJS.comSydJS.com
SydJS.com
 
How to Use Your Own Private Registry
How to Use Your Own Private RegistryHow to Use Your Own Private Registry
How to Use Your Own Private Registry
 
Deploying to DigitalOcean With GitHub Actions
Deploying to DigitalOcean With GitHub ActionsDeploying to DigitalOcean With GitHub Actions
Deploying to DigitalOcean With GitHub Actions
 
Docker worshop @Twitter - How to use your own private registry
Docker worshop @Twitter - How to use your own private registryDocker worshop @Twitter - How to use your own private registry
Docker worshop @Twitter - How to use your own private registry
 
Gojko Adzic Cucumber
Gojko Adzic CucumberGojko Adzic Cucumber
Gojko Adzic Cucumber
 
Introduzione a GitHub Actions (beta)
Introduzione a GitHub Actions (beta)Introduzione a GitHub Actions (beta)
Introduzione a GitHub Actions (beta)
 
JUGUtrecht2023 - GithubActions
JUGUtrecht2023 - GithubActionsJUGUtrecht2023 - GithubActions
JUGUtrecht2023 - GithubActions
 
Make an Instant Website with Webhooks
Make an Instant Website with WebhooksMake an Instant Website with Webhooks
Make an Instant Website with Webhooks
 
Knative build for open whisk runtimes phase 1 - 2018-02-20
Knative build for open whisk runtimes   phase 1 - 2018-02-20Knative build for open whisk runtimes   phase 1 - 2018-02-20
Knative build for open whisk runtimes phase 1 - 2018-02-20
 
Gitlab and Lingvokot
Gitlab and LingvokotGitlab and Lingvokot
Gitlab and Lingvokot
 
Jenkins Pipelines
Jenkins PipelinesJenkins Pipelines
Jenkins Pipelines
 
Introduction to Tekton
Introduction to TektonIntroduction to Tekton
Introduction to Tekton
 
Using a Private Git Server for Packaging Software
Using a Private Git Server for Packaging SoftwareUsing a Private Git Server for Packaging Software
Using a Private Git Server for Packaging Software
 
OSCONF - April 2021 - Run GitHub Actions Locally with nektos/act and Docker
OSCONF - April 2021 - Run GitHub Actions Locally with nektos/act and DockerOSCONF - April 2021 - Run GitHub Actions Locally with nektos/act and Docker
OSCONF - April 2021 - Run GitHub Actions Locally with nektos/act and Docker
 
Introduction to Github action Presentation
Introduction to Github action PresentationIntroduction to Github action Presentation
Introduction to Github action Presentation
 
Fullstack workshop
Fullstack workshopFullstack workshop
Fullstack workshop
 

More from Oleksii Holub

Reality-Driven Testing using TestContainers
Reality-Driven Testing using TestContainersReality-Driven Testing using TestContainers
Reality-Driven Testing using TestContainers
Oleksii Holub
 
Intro to CliWrap
Intro to CliWrapIntro to CliWrap
Intro to CliWrap
Oleksii Holub
 
Intro to CliWrap
Intro to CliWrapIntro to CliWrap
Intro to CliWrap
Oleksii Holub
 
Expression trees in C#
Expression trees in C#Expression trees in C#
Expression trees in C#
Oleksii Holub
 
Fallacies of unit testing
Fallacies of unit testingFallacies of unit testing
Fallacies of unit testing
Oleksii Holub
 
Expression trees in c#
Expression trees in c#Expression trees in c#
Expression trees in c#
Oleksii Holub
 
Alexey Golub - Writing parsers in c# | 3Shape Meetup
Alexey Golub - Writing parsers in c# | 3Shape MeetupAlexey Golub - Writing parsers in c# | 3Shape Meetup
Alexey Golub - Writing parsers in c# | 3Shape Meetup
Oleksii Holub
 

More from Oleksii Holub (7)

Reality-Driven Testing using TestContainers
Reality-Driven Testing using TestContainersReality-Driven Testing using TestContainers
Reality-Driven Testing using TestContainers
 
Intro to CliWrap
Intro to CliWrapIntro to CliWrap
Intro to CliWrap
 
Intro to CliWrap
Intro to CliWrapIntro to CliWrap
Intro to CliWrap
 
Expression trees in C#
Expression trees in C#Expression trees in C#
Expression trees in C#
 
Fallacies of unit testing
Fallacies of unit testingFallacies of unit testing
Fallacies of unit testing
 
Expression trees in c#
Expression trees in c#Expression trees in c#
Expression trees in c#
 
Alexey Golub - Writing parsers in c# | 3Shape Meetup
Alexey Golub - Writing parsers in c# | 3Shape MeetupAlexey Golub - Writing parsers in c# | 3Shape Meetup
Alexey Golub - Writing parsers in c# | 3Shape Meetup
 

Recently uploaded

Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 

Recently uploaded (20)

Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 

GitHub Actions in action

  • 1. Speaker: Alexey Golub @Tyrrrz GitHub Actions …in action!
  • 2. /whois ${speaker} Speaker: Alexey Golub @Tyrrrz • Open-source developer ✨ • Conference speaker & blogger 🌐️ • C#, F#, JavaScript 💻 • Cloud & web ☁️ • Automation & DevOps ⚙️
  • 3. GitHub Actions at a glance • Globally available since November 13, 2019 • Based on Azure Pipelines • Native integration with GitHub API • YAML-based configuration • Modular architecture & community-driven • Runners on Windows, Linux, macOS, or self-hosted • Available with Free, Pro, Team, Enterprise Cloud, One Speaker: Alexey Golub @Tyrrrz
  • 4. Product Storage Minutes (monthly) GitHub Free 500 MB 2,000 GitHub Pro 1 GB 3,000 GitHub Team 2 GB 10,000 GitHub Enterprise Cloud 50 GB 50,000 Speaker: Alexey Golub @Tyrrrz Free! ✨ Operating system Minute multiplier Windows 2 Linux 1 macOS 10 Private repositoriesPublic repositories Operating system Per-minute rate Windows $0.016 Linux $0.008 macOS $0.080
  • 5. GitHub Actions = IFTTT for GitHub repositories Speaker: Alexey Golub @Tyrrrz
  • 6. Speaker: Alexey Golub @Tyrrrz Add positional arguments (fixes #26) Use ValueTask in ICommand Include shared props file Add support for autocompletion How can I implement a custom converter? Add required options to help text Trigger CI build Label issue Tag reviewers Released v1.7.2 Post a message in Slack EVENT EVENT EVENT EVENT
  • 7. Speaker: Alexey Golub @Tyrrrz Workflow Trigger Job Step Job . . . Job Step . . . Step PULL REQUEST Continuous integration Build, test, coverage Scripts, actions
  • 9. Speaker: Alexey Golub @Tyrrrz ~/.github/workflows/CI.yml name: CI on: [push, pull_request] jobs: build: runs-on: windows-latest steps: - name: Checkout uses: actions/checkout@v1 - name: Install .NET Core uses: actions/setup-dotnet@v1 with: dotnet-version: 3.1.100 - name: Build & test run: dotnet test --configuration Release - name: Build & publish run: dotnet publish LightBulb/ -o LightBulb/bin/Publish/ --configuration Release - name: Upload build artifacts uses: actions/upload-artifact@master with: name: LightBulb path: LightBulb/bin/Publish/ Trigger on new commits and pull requests Clone repository and checkout HEAD (commit hash is passed as env var) Install .NET Core v3.1.100 Run custom shell scripts Upload specified directory as a ZIP artifact
  • 13. Triggers • GitHub API events ⚡ push, pull_request, issues, release, and 20 others • Schedule 🕒 Cron syntax, e.g.: */15 * * * * • Manual 🌐️ POST to /repos/:owner/:repo/dispatches Speaker: Alexey Golub @Tyrrrz
  • 14. Speaker: Alexey Golub @Tyrrrz # Trigger on push events on s pecific branches on: push: branches: - 'master' - 'release/*' # Trigger every midnight UTC on: schedule: - cron: '0 0 * * *' # Trigger on manual dispatch on: repository_dispatch # Trigger when an issue is opened o r labeled on: issues: types: [opened, labeled]
  • 15. Referencing actions • By GitHub repository 📚 {owner}/{repo}@{ref} jessfraz/branch-cleanup-action@master {owner}/{repo}/{path}@{ref} johndoe/my-actions/push-image@v1 • By file path 📁 ./path/to/dir ./.github/actions/my-action • By Docker image 🐳 docker://{image}:{tag} docker://hello-world:latest Speaker: Alexey Golub @Tyrrrz
  • 17. Matrices Speaker: Alexey Golub @Tyrrrz name: Matrix Reloaded on: [push] jobs: build: runs-on: ${{ matrix.os }} strategy: max-parallel: 4 matrix: os: [ubuntu-16.04, ubuntu-18.04] node-ver: [6, 8, 10] steps: - uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-ver }} Reference variables from the matrix Ubuntu-16.04 Ubuntu-18.04 Node v6 Node v6 Node v8 Node v8 Node v10 Node v10
  • 18. Docker containers Speaker: Alexey Golub @Tyrrrz jobs: build: services: redis: image: redis ports: - 6379/tcp options: --entrypoint redis-server steps: env: REDIS_HOST: localhost REDIS_PORT: ${{ job.services.redis.ports[6379] }} Image from the Docker registry Bind port 6379 in container to a random port on host Exposed port is resolved dynamically Custom arguments passed to docker create
  • 19. Secrets Speaker: Alexey Golub @Tyrrrz steps: # ... - name: Collect coverage report run: | choco install codecov --no-progress codecov -f LtGt.Tests/bin/Release/Coverage.xml -t ${{secrets.CODECOV_TOKEN}} Secret variable
  • 21. Speaker: Alexey Golub @Tyrrrz Secrets are automatically obfuscated in logs
  • 22. Action to action I/O Speaker: Alexey Golub @Tyrrrz - name: Create release id: create_release uses: actions/create-release@v1 - name: Upload release asset uses: actions/upload-release-asset@v1.0.1 with: upload_url: ${{ steps.create_release.outputs.upload_url }} Actions can be referenced by their ID Resolved from the outputs of another action
  • 23. Conditionals Speaker: Alexey Golub @Tyrrrz - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') run: dotnet nuget push src/**.nupkg -k ${{secrets.NUGET_TOKEN}} Conditional expression
  • 24. Things we can do with GitHub Actions • Run tests on every commit • Publish Docker image when a tag is pushed • Label an issue by content when it’s created • Run nightly E2E tests • Automatically close stale issues every week • Invite new contributors to sign the CLA when a PR is opened • Automatically format code on push • … Speaker: Alexey Golub @Tyrrrz
  • 25. Examples of actions you can use in your workflows Speaker: Alexey Golub @Tyrrrz
  • 26. actions/github-script Speaker: Alexey Golub @Tyrrrz - uses: actions/github-script@0.4.0 with: github-token: ${{secrets.GITHUB_TOKEN}} script: | github.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: '👋 Thanks for reporting!' }) Runs inline JS code that uses the GitHub API
  • 27. actions/stale Speaker: Alexey Golub @Tyrrrz - uses: actions/stale@v1 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: ’Issue closed due to inactivity.' stale-pr-message: ’PR closed due to inactivity.’ days-before-stale: 30 days-before-close: 5 Closes stale issues and PRs
  • 28. sonarsource/sonarcloud-github-action Speaker: Alexey Golub @Tyrrrz - name: SonarCloud Scan uses: sonarsource/sonarcloud-github-action@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} Sends code to SonarCloud to scan for issues
  • 29. vsoch/pull-request-action Speaker: Alexey Golub @Tyrrrz - name: pull-request-action uses: vsoch/pull-request-action@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} BRANCH_PREFIX: "features/" PULL_REQUEST_BRANCH: "master" Automatically creates a pull request when publishing a new branch
  • 31. Can’t find an action you need? Make your own! Speaker: Alexey Golub @Tyrrrz
  • 32. JavaScript-based actions • Supported by all runners • Can only use JavaScript • Requires a single self-contained .js file as the entry point • Node modules @actions/core & @actions/github Speaker: Alexey Golub @Tyrrrz action.yml index.js +
  • 33. Speaker: Alexey Golub @Tyrrrz name: 'Hello World' description: 'Greet someone and record time' inputs: who-to-greet: description: 'Who to greet' required: true default: 'World' outputs: time: description: 'The time we greeted you' runs: using: 'node12' main: 'index.js' ~/action.yml Metadata associated with an action Inputs & outputs Entry point
  • 34. Speaker: Alexey Golub @Tyrrrz const core = require('@actions/core'); const github = require('@actions/github'); try { // `who-to-greet` input defined in action metadata file const nameToGreet = core.getInput('who-to-greet'); console.log(`Hello ${nameToGreet}!`); const time = (new Date()).toTimeString(); core.setOutput("time", time); // Get the JSON webhook payload for the event that triggered the workflow const payload = JSON.stringify(github.context.payload, undefined, 2) console.log(`The event payload: ${payload}`); } catch (error) { core.setFailed(error.message); } ~/index.js
  • 35. Docker-based actions • Supported only by Linux-based runners (for now) • Can use any language or runtime • Typically runs slower Speaker: Alexey Golub @Tyrrrz action.yml Dockerfile +
  • 36. Speaker: Alexey Golub @Tyrrrz name: 'Hello World' description: 'Greet someone and record time' inputs: who-to-greet: description: 'Who to greet' required: true default: 'World' outputs: time: description: 'The time we greeted you' runs: using: 'docker' image: 'Dockerfile' args: - ${{ inputs.who-to-greet }} ~/action.yml FROM ubuntu:18.04 COPY entrypoint.sh ./ ENTRYPOINT ["/entrypoint.sh"] ~/Dockerfile #!/bin/sh -l echo "Hello $1" time=$(date) echo ::set-output name=time::$time ~/entrypoint.sh
  • 37. Speaker: Alexey Golub @Tyrrrz Special commands • ::set-output name=action_fruit::strawberry • ::set-env name=action_state::yellow • ::add-path::/path/to/dir • ::debug file=app.js,line=1::Entered method • ::warning file=app.js,line=1,col=5::Missing semicolon • ::error file=app.js,line=10,col=15::Oops • ::add-mask::Mona The Octocat
  • 38. Publishing actions to marketplace Speaker: Alexey Golub @Tyrrrz
  • 40. Summary • GitHub Actions is an automation platform (not just CI/CD) • Can trigger workflows on various events • Workflows are based on actions which are sourced by the community • Free for all public repos, pay-as-you-go for private repos • Easy to set up and configure to your needs Speaker: Alexey Golub @Tyrrrz
  • 41. For the curious • Awesome Actions by Sarah Drasner https://github.com/sdras/awesome-actions • GitHub Actions Advent Calendar by Edward Thomson https://edwardthomson.com/blog/github_actions_advent_calendar.html • Comprehensive Introduction to GitHub Actions by Tierney Cyren https://dev.to/bnb/an-unintentionally-comprehensive-introduction-to- github-actions-ci-blm • Official documentation https://help.github.com/en/actions Speaker: Alexey Golub @Tyrrrz