SlideShare une entreprise Scribd logo
1  sur  53
Télécharger pour lire hors ligne
Ixchel Ruiz
Lights, Camera, GitHub Actions!
@ Utrecht JUG
Ixchel Ruiz
Senior Software Developer, DA @JFrog
@ixchelruiz@mastodon.social
www.linkedin.com/in/ixchelruiz
Github Actions
Github: Octoverse 2022
94M developers are on GitHub
Languages on GitHub → 1st JavaScript, 2nd Python, 3rd Java
Github Actions
Github Actions
Automated testing
Automatically responding to new issues, mentions
Triggering code reviews
Handling pull requests
Branch management
Github Actions : What?
Actions are the mechanism used to provide workflow
automation within the GitHub environment.
Github Actions : What?
Defined in YAML and stay within GitHub repositories
Executed on "runners," either hosted by GitHub or self-hosted
Contributed actions can be found in the GitHub Marketplace
Events
Work
fl
ows
Jobs
Actions
Trigger
Contain
Use
Github Actions
Name: name of the work
fl
ow
On: event or list that will trigger the work
fl
ow
Jobs: list of jobs to be executed
Runs-on: runner to use
Steps: list of steps (within a job executed on the same
runner)
Uses: prede
fi
ned action to be retrieved
Run: execute a command on the runner
inputs
github.event.inputs
Inputs
Workflow triggers : Events
Events
Events that occur in the work
fl
ow's repository
Events that occur outside of GitHub and trigger
a repository_dispatch event on GitHub
Scheduled times
Manual
Events
branch_protection_rule
check_run
check_suite
create
delete
deployment
deployment_status
discussion
discussion_comment
fork
gollum
issue_comment
issues
label
milestone
page_build
project
project_card
project_column
public
pull_request
pull_request_comment(use issue_comment)
pull_request_review
pull_request_review_comment
pull_request_target push
registry_package
release
repository_dispatch
schedule
status
watch
work
fl
ow_call
work
fl
ow_dispatch
work
fl
ow_run
Events
branch_protection_rule
check_run
check_suite
create
delete
deployment
deployment_status
discussion
discussion_comment
fork
gollum
issue_comment
issues
label
milestone
page_build
project
project_card
project_column
public
pull_request
pull_request_comment(use issue_comment)
pull_request_review
pull_request_review_comment
pull_request_target push
registry_package
release
repository_dispatch
schedule
status
watch
work
fl
ow_call
work
fl
ow_dispatch
work
fl
ow_run
Events
on:
gollum
Work
fl
ows can be executed when a GitHub webhook is called
This event would
fi
re when someone updates or
fi
rst creates a Wiki
page
Scheduling
Scheduling
on:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '30 5,17 * * *'
Every day at 5:30 and 17:30 UTC
Cron schedules are based on
fi
ve values:
Minute (0 - 59)
Hour (0 - 23)
Day of the month (1 - 31)
Month (1 - 12)
Day of the week (0 - 6)
on:
schedule:
- cron: '30 5 * * 1,3'
- cron: '30 5 * * 2,4'
jobs:
test_schedule:
runs-on: ubuntu-latest
steps:
- name: Not on Monday or Wednesday
if: github.event.schedule != '30 5 * * 1,3'
run: echo "This step will be skipped on Monday and Wednesday"
- name: Every time
run: echo "This step will always run"
cron: '30 5,17 * * *'
cron: '30 5 * * 1,3’
cron: '30 5 * * 2,4’
if: github.event.schedule != '30 5 * * 1,3'
Conditionals
jobs:
production-deploy:
if: github.repository == 'octo-org/octo-
repo-prod'
runs-on: ubuntu-latest
steps:
- name: My
fi
rst step
if: ${{ github.event_name == 'pull_request'
&& github.event.action == 'unassigned' }}
run: echo “This event is a pull request that
had an assignee removed”
if: github.repository == ‘octo-org/octo-repo-prod'
if: ${{ github.event_name == 'pull_request' && github.event.action == 'unassigned' }}
Filters
Filters
on:
pull_request:
types:
- opened
branches:
- 'releases/**'
paths:
- '**.js'
will only run when all
fi
lters are satis
fi
ed.
will only run when a pull request that includes a change to a JavaScript (.js)
fi
le is opened on a branch whose name starts with releases/
Filters : Refs
on:
pull_request:
# patterns refs/heads
branches-ignore:
- 'mona/octocat'
- ‘releases/**-alpha’
on:
pull_request:
branches:
- 'releases/**'
- '!releases/**-alpha'
branches-ignore branches: !
Filters: Tags
on:
push:
# patterns refs/heads
branches:
- main
- 'mona/octocat'
- 'releases/**'
# patterns refs/tags
tags:
- v2
- v1.*
on:
push:
#patterns refs/heads
branches-ignore:
- 'mona/octocat'
- 'releases/**-alpha'
# patterns refs/tags
tags-ignore:
- v2
- v1.*
will only run when all
fi
lters are satis
fi
ed.
tags-ignore
tags
Jobs
Jobs
Work
fl
ows contain one or more jobs
A job is a set of steps that will be run in order on a runner.
Steps within a job execute on the same runner and share the same
fi
lesystem
The logs produced by jobs are searchable
Jobs : Run
Jobs run in parallel by default.
sequentially → de
fi
ne dependencies ( needs )
needs
Defining prerequisite jobs
Prerequisite jobs: Expressions
jobs:
job1:
job2:
needs: job1
job3:
needs: [job1, job2]
*Requiring successful dependent jobs
jobs:
job1:
job2:
needs: job1
job3:
if: ${{ always() }}
needs: [job1, job2]
*Not requiring successful dependent jobs
if: ${{ always() }}
needs
Permissions
Permissions
actions: read | write | none
checks: read | write | none
contents: read | write | none
deployments: read | write | none
id-token: read | write | none
issues: read | write | none
discussions: read | write | none
packages: read | write | none
pages: read | write | none
pull-requests: read | write | none
repository-projects: read | write | none
security-events: read | write | none
statuses: read | write | none
permissions
permissions
Concurrency
Concurrency
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
concurrency:
group: ${{ github.work
fl
ow }}-${{ github.ref }}
cancel-in-progress: true
Using concurrency to cancel any in-progress job or run
Only cancel in-progress jobs or runs for the current work
fl
ow
Using a fallback value
concurrency:
group: '${{ github.work
fl
ow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
Reusable Workflows
Reusable Workflows
A work
fl
ow that uses another work
fl
ow is referred to as a "caller"
work
fl
ow.
The reusable work
fl
ow is a "called" work
fl
ow.
One "caller" work
fl
ow can use multiple "called" work
fl
ows.
Each "called" work
fl
ow is referenced in a single line.
Reusable Workflows
When a reusable work
fl
ow is triggered by a caller work
fl
ow, the github
context is always associated with the caller work
fl
ow.
The called work
fl
ow is automatically granted access to
github.token and secrets.GITHUB_TOKEN.
Reusable Workflows : outputs
name: Reusable work
fl
ow
on:
work
fl
ow_call:
# Map the work
fl
ow outputs to job outputs
outputs:
fi
rstword:
description: "The
fi
rst output string"
value: ${{ jobs.example_job.outputs.output1 }}
secondword:
description: "The second output string"
value: ${{ jobs.example_job.outputs.output2 }}
jobs:
example_job:
name: Generate output
runs-on: ubuntu-latest
# Map the job outputs to step outputs
outputs:
output1: ${{ steps.step1.outputs.
fi
rstword }}
output2: ${{ steps.step2.outputs.secondword }}
steps:
- id: step1
run: echo "
fi
rstword=hello" >> $GITHUB_OUTPUT
- id: step2
run: echo "secondword=world" >> $GITHUB_OUTPUT
name: Call a reusable work
fl
ow and use its outputs
on:
work
fl
ow_dispatch:
jobs:
job1:
uses: octo-org/example-repo/.github/work
fl
ows/called-work
fl
ow.yml@v1
job2:
runs-on: ubuntu-latest
needs: job1
steps:
- run: echo ${{ needs.job1.outputs.
fi
rstword }} ${{ needs.job1.outputs.secondword }}
called ( called-work
fl
ow.yml ) caller work
fl
ow
Reusable Workflows : secrets
jobs:
work
fl
owA-calls-work
fl
owB:
uses: octo-org/example-
repo/.github/work
fl
ows/B.yml@main
secrets: inherit
# pass all secrets
jobs:
work
fl
owB-calls-work
fl
owC:
uses: different-org/example-
repo/.github/work
fl
ows/C.yml@main
secrets:
envPAT: ${{ secrets.envPAT }}
# pass just this secret
B will inherit ALL secrets C will inherit envPAT secret
Reusable Workflows : Limitation
• Connect up to 4 levels of work
fl
ows
• Call a maximum of 20 reusable work
fl
ows
• Env variables ( env context @ caller work
fl
ow) not propagated to
called
• Env variables ( env context @ called work
fl
ow) not accessible to
caller Use outputs
• Reuse variables multiple work
fl
ows —> organization, repository, or environment levels (vars context)
• Reusable work
fl
ows (within a job and not step)
Secrets
Secrets
Secrets use Libsodium sealed boxes, so that they are encrypted
before reaching GitHub.
Never use structured data as a secret. Github attempts to redact any secrets that appear in run logs.
With the exception of GITHUB_TOKEN, secrets are not passed to the
runner when a work
fl
ow is triggered from a forked repository.
Secrets cannot be directly referenced in if: conditionals.
Register all secrets used within work
fl
ows
Demo
THANK YOU!

Contenu connexe

Similaire à JUGUtrecht2023 - GithubActions

Node.js basics
Node.js basicsNode.js basics
Node.js basics
Ben Lin
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
ronnywang_tw
 
Desarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutosDesarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutos
Edgar Suarez
 
Background Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRbBackground Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRb
Juan Maiz
 

Similaire à JUGUtrecht2023 - GithubActions (20)

Oliver hookins puppetcamp2011
Oliver hookins puppetcamp2011Oliver hookins puppetcamp2011
Oliver hookins puppetcamp2011
 
Puppi. Puppet strings to the shell
Puppi. Puppet strings to the shellPuppi. Puppet strings to the shell
Puppi. Puppet strings to the shell
 
Node.js basics
Node.js basicsNode.js basics
Node.js basics
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with Ansible
 
Dataflow: Declarative concurrency in Ruby
Dataflow: Declarative concurrency in RubyDataflow: Declarative concurrency in Ruby
Dataflow: Declarative concurrency in Ruby
 
Gevent be or not to be
Gevent be or not to beGevent be or not to be
Gevent be or not to be
 
«Gevent — быть или не быть?» Александр Мокров, Positive Technologies
«Gevent — быть или не быть?» Александр Мокров, Positive Technologies«Gevent — быть или не быть?» Александр Мокров, Positive Technologies
«Gevent — быть или не быть?» Александр Мокров, Positive Technologies
 
とりあえずはじめるChatOps
とりあえずはじめるChatOpsとりあえずはじめるChatOps
とりあえずはじめるChatOps
 
To Batch Or Not To Batch
To Batch Or Not To BatchTo Batch Or Not To Batch
To Batch Or Not To Batch
 
Explore the Rake Gem
Explore the Rake GemExplore the Rake Gem
Explore the Rake Gem
 
Ruby/Rails
Ruby/RailsRuby/Rails
Ruby/Rails
 
Tdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema RubyTdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema Ruby
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
 
Desarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutosDesarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutos
 
Host any project in che with stacks & chefiles
Host any project in che with stacks & chefilesHost any project in che with stacks & chefiles
Host any project in che with stacks & chefiles
 
Background Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRbBackground Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRb
 
Introduzione a GitHub Actions (beta)
Introduzione a GitHub Actions (beta)Introduzione a GitHub Actions (beta)
Introduzione a GitHub Actions (beta)
 
Oojs 1.1
Oojs 1.1Oojs 1.1
Oojs 1.1
 
2009 cluster user training
2009 cluster user training2009 cluster user training
2009 cluster user training
 
Jenkins Pipelines
Jenkins PipelinesJenkins Pipelines
Jenkins Pipelines
 

Plus de Ixchel Ruiz

Plus de Ixchel Ruiz (10)

Failure is not an option
Failure is not an optionFailure is not an option
Failure is not an option
 
Failure is not an option
Failure is not an option Failure is not an option
Failure is not an option
 
JCConf.tw 2022 - DevOps for Java developers
JCConf.tw 2022 - DevOps for Java developersJCConf.tw 2022 - DevOps for Java developers
JCConf.tw 2022 - DevOps for Java developers
 
All about dependencies
All about dependenciesAll about dependencies
All about dependencies
 
DevoxxMA_MavenPuzzlers.pdf
DevoxxMA_MavenPuzzlers.pdfDevoxxMA_MavenPuzzlers.pdf
DevoxxMA_MavenPuzzlers.pdf
 
(De) Human Future
(De) Human Future(De) Human Future
(De) Human Future
 
DevoxxMA : The WHY series: Metrics
DevoxxMA : The WHY series: MetricsDevoxxMA : The WHY series: Metrics
DevoxxMA : The WHY series: Metrics
 
Voxxed Banff 2018 : Containers & Integration tests
Voxxed Banff 2018 : Containers & Integration testsVoxxed Banff 2018 : Containers & Integration tests
Voxxed Banff 2018 : Containers & Integration tests
 
Testing libraries for fun & profit. Beware: Increased productivity ahead
Testing libraries for fun & profit. Beware: Increased productivity aheadTesting libraries for fun & profit. Beware: Increased productivity ahead
Testing libraries for fun & profit. Beware: Increased productivity ahead
 
DevoxxUK one size fits all
DevoxxUK   one size fits allDevoxxUK   one size fits all
DevoxxUK one size fits all
 

Dernier

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Dernier (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

JUGUtrecht2023 - GithubActions