SlideShare a Scribd company logo
1 of 42
Download to read offline
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

Introduction to Github Actions
Introduction to Github ActionsIntroduction to Github Actions
Introduction to Github ActionsKnoldus Inc.
 
Intro to Github Actions @likecoin
Intro to Github Actions @likecoinIntro to Github Actions @likecoin
Intro to Github Actions @likecoinWilliam Chong
 
Continuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CIContinuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CIDavid Hahn
 
Git Lab Introduction
Git Lab IntroductionGit Lab Introduction
Git Lab IntroductionKrunal Doshi
 
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...Edureka!
 
Introduction to Github Actions
Introduction to Github ActionsIntroduction to Github Actions
Introduction to Github ActionsKnoldus Inc.
 
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCDKubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCDSunnyvale
 
Devops Porto - CI/CD at Gitlab
Devops Porto - CI/CD at GitlabDevops Porto - CI/CD at Gitlab
Devops Porto - CI/CD at GitlabFilipa Lacerda
 
Gitlab ci, cncf.sk
Gitlab ci, cncf.skGitlab ci, cncf.sk
Gitlab ci, cncf.skJuraj Hantak
 
CI with Gitlab & Docker
CI with Gitlab & DockerCI with Gitlab & Docker
CI with Gitlab & DockerJoerg Henning
 
GitOps with ArgoCD
GitOps with ArgoCDGitOps with ArgoCD
GitOps with ArgoCDCloudOps2005
 
GitOps and ArgoCD
GitOps and ArgoCDGitOps and ArgoCD
GitOps and ArgoCDOmar Fathy
 
CD using ArgoCD(KnolX).pdf
CD using ArgoCD(KnolX).pdfCD using ArgoCD(KnolX).pdf
CD using ArgoCD(KnolX).pdfKnoldus Inc.
 
GitHub Actions with Node.js
GitHub Actions with Node.jsGitHub Actions with Node.js
GitHub Actions with Node.jsStefan Stölzle
 
Jenkins vs GitLab CI
Jenkins vs GitLab CIJenkins vs GitLab CI
Jenkins vs GitLab CICEE-SEC(R)
 
GitOps - Operation By Pull Request
GitOps - Operation By Pull RequestGitOps - Operation By Pull Request
GitOps - Operation By Pull RequestKasper Nissen
 

What's hot (20)

Introduction to Github Actions
Introduction to Github ActionsIntroduction to Github Actions
Introduction to Github Actions
 
Gitlab CI/CD
Gitlab CI/CDGitlab CI/CD
Gitlab CI/CD
 
Intro to Github Actions @likecoin
Intro to Github Actions @likecoinIntro to Github Actions @likecoin
Intro to Github Actions @likecoin
 
Continuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CIContinuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CI
 
Git Lab Introduction
Git Lab IntroductionGit Lab Introduction
Git Lab Introduction
 
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
 
Introduction to Github Actions
Introduction to Github ActionsIntroduction to Github Actions
Introduction to Github Actions
 
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCDKubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
 
Git & GitLab
Git & GitLabGit & GitLab
Git & GitLab
 
Devops Porto - CI/CD at Gitlab
Devops Porto - CI/CD at GitlabDevops Porto - CI/CD at Gitlab
Devops Porto - CI/CD at Gitlab
 
Gitlab ci, cncf.sk
Gitlab ci, cncf.skGitlab ci, cncf.sk
Gitlab ci, cncf.sk
 
CI with Gitlab & Docker
CI with Gitlab & DockerCI with Gitlab & Docker
CI with Gitlab & Docker
 
Gitlab, GitOps & ArgoCD
Gitlab, GitOps & ArgoCDGitlab, GitOps & ArgoCD
Gitlab, GitOps & ArgoCD
 
GitOps with ArgoCD
GitOps with ArgoCDGitOps with ArgoCD
GitOps with ArgoCD
 
github-actions.pdf
github-actions.pdfgithub-actions.pdf
github-actions.pdf
 
GitOps and ArgoCD
GitOps and ArgoCDGitOps and ArgoCD
GitOps and ArgoCD
 
CD using ArgoCD(KnolX).pdf
CD using ArgoCD(KnolX).pdfCD using ArgoCD(KnolX).pdf
CD using ArgoCD(KnolX).pdf
 
GitHub Actions with Node.js
GitHub Actions with Node.jsGitHub Actions with Node.js
GitHub Actions with Node.js
 
Jenkins vs GitLab CI
Jenkins vs GitLab CIJenkins vs GitLab CI
Jenkins vs GitLab CI
 
GitOps - Operation By Pull Request
GitOps - Operation By Pull RequestGitOps - Operation By Pull Request
GitOps - Operation By Pull Request
 

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 actionDevOps_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 GitHubMarc 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
 
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 RegistryDocker, Inc.
 
Deploying to DigitalOcean With GitHub Actions
Deploying to DigitalOcean With GitHub ActionsDeploying to DigitalOcean With GitHub Actions
Deploying to DigitalOcean With GitHub ActionsDigitalOcean
 
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 registrydotCloud
 
Gojko Adzic Cucumber
Gojko Adzic CucumberGojko Adzic Cucumber
Gojko Adzic CucumberSkills 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 - GithubActionsIxchel Ruiz
 
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 AzureKasun Kodagoda
 
Make an Instant Website with Webhooks
Make an Instant Website with WebhooksMake an Instant Website with Webhooks
Make an Instant Website with WebhooksAnne 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-20Matt Rutkowski
 
Gitlab and Lingvokot
Gitlab and LingvokotGitlab and Lingvokot
Gitlab and LingvokotLingvokot
 
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 SoftwareChris 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 DockerGaurav Gahlot
 
Introduction to Github action Presentation
Introduction to Github action PresentationIntroduction to Github action Presentation
Introduction to Github action PresentationKnoldus Inc.
 

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
 
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
 
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
 

More from Oleksii Holub

Reality-Driven Testing using TestContainers
Reality-Driven Testing using TestContainersReality-Driven Testing using TestContainers
Reality-Driven Testing using TestContainersOleksii 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 testingOleksii 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 MeetupOleksii 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

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 

Recently uploaded (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

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