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

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
 
Kubernetes
KubernetesKubernetes
Kuberneteserialc_w
 
Continuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CIContinuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CIDavid Hahn
 
Introduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionIntroduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionAnwarul Islam
 
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 ActionsCasey Lee
 
The journey to GitOps
The journey to GitOpsThe journey to GitOps
The journey to GitOpsNicola Baldi
 
Gitlab ci, cncf.sk
Gitlab ci, cncf.skGitlab ci, cncf.sk
Gitlab ci, cncf.skJuraj Hantak
 
GitHub Actions with Node.js
GitHub Actions with Node.jsGitHub Actions with Node.js
GitHub Actions with Node.jsStefan Stölzle
 
Yale Jenkins Show and Tell
Yale Jenkins Show and TellYale Jenkins Show and Tell
Yale Jenkins Show and TellE. Camden Fisher
 
CI with Gitlab & Docker
CI with Gitlab & DockerCI with Gitlab & Docker
CI with Gitlab & DockerJoerg Henning
 
Introduction to Github Actions
Introduction to Github ActionsIntroduction to Github Actions
Introduction to Github ActionsKnoldus Inc.
 
Kubernetes Networking
Kubernetes NetworkingKubernetes Networking
Kubernetes NetworkingCJ Cullen
 
GitOps: Git come unica fonte di verità per applicazioni e infrastruttura
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 infrastrutturasparkfabrik
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notesglen_a_smith
 
Gitops: the kubernetes way
Gitops: the kubernetes wayGitops: the kubernetes way
Gitops: the kubernetes waysparkfabrik
 

What's hot (20)

CI/CD with Github Actions
CI/CD with Github ActionsCI/CD with Github Actions
CI/CD with Github Actions
 
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
 
github-actions.pdf
github-actions.pdfgithub-actions.pdf
github-actions.pdf
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
Continuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CIContinuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CI
 
Introduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionIntroduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training Session
 
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
 
The journey to GitOps
The journey to GitOpsThe journey to GitOps
The journey to GitOps
 
Gitlab ci, cncf.sk
Gitlab ci, cncf.skGitlab ci, cncf.sk
Gitlab ci, cncf.sk
 
GitHub Actions with Node.js
GitHub Actions with Node.jsGitHub Actions with Node.js
GitHub Actions with Node.js
 
Gitlab, GitOps & ArgoCD
Gitlab, GitOps & ArgoCDGitlab, GitOps & ArgoCD
Gitlab, GitOps & ArgoCD
 
Yale Jenkins Show and Tell
Yale Jenkins Show and TellYale Jenkins Show and Tell
Yale Jenkins Show and Tell
 
CI with Gitlab & Docker
CI with Gitlab & DockerCI with Gitlab & Docker
CI with Gitlab & Docker
 
Introducing GitLab
Introducing GitLabIntroducing GitLab
Introducing GitLab
 
Introduction to Github Actions
Introduction to Github ActionsIntroduction to Github Actions
Introduction to Github Actions
 
Jenkins CI
Jenkins CIJenkins CI
Jenkins CI
 
Kubernetes Networking
Kubernetes NetworkingKubernetes Networking
Kubernetes Networking
 
GitOps: Git come unica fonte di verità per applicazioni e infrastruttura
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
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Gitops: the kubernetes way
Gitops: the kubernetes wayGitops: the kubernetes way
Gitops: the kubernetes way
 

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
 
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.
 
Fullstack workshop
Fullstack workshopFullstack workshop
Fullstack workshopAssaf 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 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

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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
 

Recently uploaded (20)

Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 

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