GitHub Actions in action

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
1 of 42

Recommended

Intro to Github Actions @likecoin by
Intro to Github Actions @likecoinIntro to Github Actions @likecoin
Intro to Github Actions @likecoinWilliam Chong
202 views16 slides
Github in Action by
Github in ActionGithub in Action
Github in ActionMorten Christensen
192 views50 slides
DevOps with GitHub Actions by
DevOps with GitHub ActionsDevOps with GitHub Actions
DevOps with GitHub ActionsNilesh Gule
371 views21 slides
Introduction to GitHub Actions by
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub ActionsBo-Yi Wu
19.3K views57 slides
Introduction to GitHub Actions by
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub ActionsKnoldus Inc.
3.2K views16 slides
CICD Pipeline Using Github Actions by
CICD Pipeline Using Github ActionsCICD Pipeline Using Github Actions
CICD Pipeline Using Github ActionsKumar Shìvam
516 views21 slides

More Related Content

What's hot

github-actions.pdf by
github-actions.pdfgithub-actions.pdf
github-actions.pdfAbhaymithraReddy1
127 views76 slides
Container based CI/CD on GitHub Actions by
Container based CI/CD on GitHub ActionsContainer based CI/CD on GitHub Actions
Container based CI/CD on GitHub ActionsCasey Lee
346 views22 slides
Introduction to Github Actions by
Introduction to Github ActionsIntroduction to Github Actions
Introduction to Github ActionsKnoldus Inc.
479 views13 slides
Gitlab CI/CD by
Gitlab CI/CDGitlab CI/CD
Gitlab CI/CDJEMLI Fathi
1.1K views17 slides
GitLab.pptx by
GitLab.pptxGitLab.pptx
GitLab.pptxLeoulZewelde1
325 views16 slides
Using GitHub Actions to Deploy your Workloads to Azure by
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
258 views30 slides

What's hot(20)

Container based CI/CD on GitHub Actions by Casey Lee
Container based CI/CD on GitHub ActionsContainer based CI/CD on GitHub Actions
Container based CI/CD on GitHub Actions
Casey Lee346 views
Introduction to Github Actions by Knoldus Inc.
Introduction to Github ActionsIntroduction to Github Actions
Introduction to Github Actions
Knoldus Inc.479 views
Using GitHub Actions to Deploy your Workloads to Azure by Kasun Kodagoda
Using GitHub Actions to Deploy your Workloads to AzureUsing GitHub Actions to Deploy your Workloads to Azure
Using GitHub Actions to Deploy your Workloads to Azure
Kasun Kodagoda258 views
FOSDEM 2017: GitLab CI by OlinData
FOSDEM 2017:  GitLab CIFOSDEM 2017:  GitLab CI
FOSDEM 2017: GitLab CI
OlinData1.1K views
Introduction to Github Actions by Knoldus Inc.
Introduction to Github ActionsIntroduction to Github Actions
Introduction to Github Actions
Knoldus Inc.57 views
What's New for GitLab CI/CD February 2020 by Noa Harel
What's New for GitLab CI/CD February 2020What's New for GitLab CI/CD February 2020
What's New for GitLab CI/CD February 2020
Noa Harel636 views
Continuous Integration/Deployment with Gitlab CI by David Hahn
Continuous Integration/Deployment with Gitlab CIContinuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CI
David Hahn5.9K views
Continuous Delivery, Continuous Integration by Amazon Web Services
Continuous Delivery, Continuous Integration Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration
Amazon Web Services3.6K views
Introduction to GitHub by Nishan Bose
Introduction to GitHubIntroduction to GitHub
Introduction to GitHub
Nishan Bose2.1K views
Build CICD Pipeline for Container Presentation Slides by Amazon Web Services
Build CICD Pipeline for Container Presentation SlidesBuild CICD Pipeline for Container Presentation Slides
Build CICD Pipeline for Container Presentation Slides
Amazon Web Services10.5K views
Introduction to Gitlab by Julien Pivotto
Introduction to GitlabIntroduction to Gitlab
Introduction to Gitlab
Julien Pivotto20.7K views

Similar to GitHub Actions in action

DevOps Fest 2020. Alexey Golub. GitHub Actions in action by
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
136 views43 slides
Alexey Golub - Dependency absolution (application as a pipeline) | Svitla Sma... by
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
172 views73 slides
DWX 2022 - DevSecOps mit GitHub by
DWX 2022 - DevSecOps mit GitHubDWX 2022 - DevSecOps mit GitHub
DWX 2022 - DevSecOps mit GitHubMarc Müller
27 views88 slides
Introduction to GitHub Actions - How to easily automate and integrate with Gi... by
Introduction to GitHub Actions - How to easily automate and integrate with Gi...Introduction to GitHub Actions - How to easily automate and integrate with Gi...
Introduction to GitHub Actions - How to easily automate and integrate with Gi...All Things Open
109 views35 slides
SydJS.com by
SydJS.comSydJS.com
SydJS.comLachlan Hardy
786 views51 slides
How to Use Your Own Private Registry by
How to Use Your Own Private RegistryHow to Use Your Own Private Registry
How to Use Your Own Private RegistryDocker, Inc.
509 views19 slides

Similar to GitHub Actions in action(20)

DevOps Fest 2020. Alexey Golub. GitHub Actions in action by DevOps_Fest
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_Fest136 views
Alexey Golub - Dependency absolution (application as a pipeline) | Svitla Sma... by Oleksii Holub
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 Holub172 views
DWX 2022 - DevSecOps mit GitHub by Marc Müller
DWX 2022 - DevSecOps mit GitHubDWX 2022 - DevSecOps mit GitHub
DWX 2022 - DevSecOps mit GitHub
Marc Müller27 views
Introduction to GitHub Actions - How to easily automate and integrate with Gi... by All Things Open
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 Open109 views
How to Use Your Own Private Registry by Docker, Inc.
How to Use Your Own Private RegistryHow to Use Your Own Private Registry
How to Use Your Own Private Registry
Docker, Inc.509 views
Deploying to DigitalOcean With GitHub Actions by DigitalOcean
Deploying to DigitalOcean With GitHub ActionsDeploying to DigitalOcean With GitHub Actions
Deploying to DigitalOcean With GitHub Actions
DigitalOcean67 views
Docker worshop @Twitter - How to use your own private registry by dotCloud
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
dotCloud7.4K views
Introduzione a GitHub Actions (beta) by Giulio Vian
Introduzione a GitHub Actions (beta)Introduzione a GitHub Actions (beta)
Introduzione a GitHub Actions (beta)
Giulio Vian296 views
JUGUtrecht2023 - GithubActions by Ixchel Ruiz
JUGUtrecht2023 - GithubActionsJUGUtrecht2023 - GithubActions
JUGUtrecht2023 - GithubActions
Ixchel Ruiz4 views
Make an Instant Website with Webhooks by Anne Gentle
Make an Instant Website with WebhooksMake an Instant Website with Webhooks
Make an Instant Website with Webhooks
Anne Gentle871 views
Knative build for open whisk runtimes phase 1 - 2018-02-20 by Matt Rutkowski
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 Rutkowski142 views
Gitlab and Lingvokot by Lingvokot
Gitlab and LingvokotGitlab and Lingvokot
Gitlab and Lingvokot
Lingvokot597 views
Using a Private Git Server for Packaging Software by Chris Jean
Using a Private Git Server for Packaging SoftwareUsing a Private Git Server for Packaging Software
Using a Private Git Server for Packaging Software
Chris Jean1.2K views
OSCONF - April 2021 - Run GitHub Actions Locally with nektos/act and Docker by Gaurav Gahlot
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 Gahlot114 views

More from Oleksii Holub

Intro to CliWrap by
Intro to CliWrapIntro to CliWrap
Intro to CliWrapOleksii Holub
270 views8 slides
Intro to CliWrap by
Intro to CliWrapIntro to CliWrap
Intro to CliWrapOleksii Holub
578 views8 slides
Expression trees in C# by
Expression trees in C#Expression trees in C#
Expression trees in C#Oleksii Holub
58 views63 slides
Fallacies of unit testing by
Fallacies of unit testingFallacies of unit testing
Fallacies of unit testingOleksii Holub
81 views52 slides
Expression trees in c# by
Expression trees in c#Expression trees in c#
Expression trees in c#Oleksii Holub
156 views72 slides
Alexey Golub - Writing parsers in c# | 3Shape Meetup by
Alexey Golub - Writing parsers in c# | 3Shape MeetupAlexey Golub - Writing parsers in c# | 3Shape Meetup
Alexey Golub - Writing parsers in c# | 3Shape MeetupOleksii Holub
212 views18 slides

More from Oleksii Holub(6)

Alexey Golub - Writing parsers in c# | 3Shape Meetup by Oleksii Holub
Alexey Golub - Writing parsers in c# | 3Shape MeetupAlexey Golub - Writing parsers in c# | 3Shape Meetup
Alexey Golub - Writing parsers in c# | 3Shape Meetup
Oleksii Holub212 views

Recently uploaded

TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors by
TouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective SensorsTouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective Sensors
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensorssugiuralab
19 views15 slides
Scaling Knowledge Graph Architectures with AI by
Scaling Knowledge Graph Architectures with AIScaling Knowledge Graph Architectures with AI
Scaling Knowledge Graph Architectures with AIEnterprise Knowledge
28 views15 slides
Melek BEN MAHMOUD.pdf by
Melek BEN MAHMOUD.pdfMelek BEN MAHMOUD.pdf
Melek BEN MAHMOUD.pdfMelekBenMahmoud
14 views1 slide
Spesifikasi Lengkap ASUS Vivobook Go 14 by
Spesifikasi Lengkap ASUS Vivobook Go 14Spesifikasi Lengkap ASUS Vivobook Go 14
Spesifikasi Lengkap ASUS Vivobook Go 14Dot Semarang
37 views1 slide
Unit 1_Lecture 2_Physical Design of IoT.pdf by
Unit 1_Lecture 2_Physical Design of IoT.pdfUnit 1_Lecture 2_Physical Design of IoT.pdf
Unit 1_Lecture 2_Physical Design of IoT.pdfStephenTec
12 views36 slides
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...James Anderson
66 views32 slides

Recently uploaded(20)

TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors by sugiuralab
TouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective SensorsTouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective Sensors
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors
sugiuralab19 views
Spesifikasi Lengkap ASUS Vivobook Go 14 by Dot Semarang
Spesifikasi Lengkap ASUS Vivobook Go 14Spesifikasi Lengkap ASUS Vivobook Go 14
Spesifikasi Lengkap ASUS Vivobook Go 14
Dot Semarang37 views
Unit 1_Lecture 2_Physical Design of IoT.pdf by StephenTec
Unit 1_Lecture 2_Physical Design of IoT.pdfUnit 1_Lecture 2_Physical Design of IoT.pdf
Unit 1_Lecture 2_Physical Design of IoT.pdf
StephenTec12 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson66 views
Case Study Copenhagen Energy and Business Central.pdf by Aitana
Case Study Copenhagen Energy and Business Central.pdfCase Study Copenhagen Energy and Business Central.pdf
Case Study Copenhagen Energy and Business Central.pdf
Aitana16 views
PharoJS - Zürich Smalltalk Group Meetup November 2023 by Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi126 views
Attacking IoT Devices from a Web Perspective - Linux Day by Simone Onofri
Attacking IoT Devices from a Web Perspective - Linux Day Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day
Simone Onofri15 views
The details of description: Techniques, tips, and tangents on alternative tex... by BookNet Canada
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada126 views
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
DALI Basics Course 2023 by Ivory Egg
DALI Basics Course  2023DALI Basics Course  2023
DALI Basics Course 2023
Ivory Egg16 views
SAP Automation Using Bar Code and FIORI.pdf by Virendra Rai, PMP
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdf
Transcript: The Details of Description Techniques tips and tangents on altern... by BookNet Canada
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...
BookNet Canada135 views
From chaos to control: Managing migrations and Microsoft 365 with ShareGate! by sammart93
From chaos to control: Managing migrations and Microsoft 365 with ShareGate!From chaos to control: Managing migrations and Microsoft 365 with ShareGate!
From chaos to control: Managing migrations and Microsoft 365 with ShareGate!
sammart939 views
Perth MeetUp November 2023 by Michael Price
Perth MeetUp November 2023 Perth MeetUp November 2023
Perth MeetUp November 2023
Michael Price19 views

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