Slide 1

Slide 1 text

6th June 2019 DevOps Thames Valley/GitHub GitHub Actions What are they, how to use them, and why you might want to!

Slide 2

Slide 2 text

GitHub Actions DevOps Thames Valley/GitHub - Who am I? - Why should you listen to me? - What are we going to cover? Welcome

Slide 3

Slide 3 text

DevOps Thames Valley/GitHub GitHub Actions Actions: What Are They?

Slide 4

Slide 4 text

DevOps Thames Valley/GitHub GitHub Actions •No infrastructure required •Can be written in any language •Shareable on the GitHub Marketplace •Are now also able to be scheduled What is a GitHub Action? TL;DR Code that runs when something happens to or in a GitHub repository

Slide 5

Slide 5 text

DevOps Thames Valley/GitHub GitHub Actions •Metadata about the event that triggered it •Any publicly available API, including the GitHub API •Secrets •Shared workspace, including a copy of the repository What can an Action Access?

Slide 6

Slide 6 text

DevOps Thames Valley/GitHub GitHub Actions What can trigger an Action?

Slide 7

Slide 7 text

DevOps Thames Valley/GitHub GitHub Actions •Actions are run in order, and can be run in parallel •Editable in a visual editor on GitHub.com or a text editor •Any Action can halt a workflow with neutral or failed statuses What is an Action workflow? TL;DR Any number of Actions chained together in a DAG

Slide 8

Slide 8 text

DevOps Thames Valley/GitHub GitHub Actions How To Use Actions

Slide 9

Slide 9 text

DevOps Thames Valley/GitHub GitHub Actions .github/main.workflow GitHub looks for files with the .workflow extension in a repository’s .github folder.

Slide 10

Slide 10 text

DevOps Thames Valley/GitHub GitHub Actions workflow "Test my code" { on = "push" resolves = ["npm test"] } action "npm install" { uses = "actions/npm@master" args = ["install"] } action "npm test" { uses = "actions/npm@master" args = ["test"] needs = ["npm install"] }

Slide 11

Slide 11 text

DevOps Thames Valley/GitHub GitHub Actions Key Points A workflow can contain 100 actions A workflow can run for up to 58 minutes An action cannot trigger other workflows An action must point to a valid Dockerfile

Slide 12

Slide 12 text

GitHub Actions DevOps Thames Valley/GitHub LABEL "com.github.actions.name"="Slack Bot Action" LABEL "com.github.actions.description"="A GitHub Action that posts a message to Slack either from hardcoded strings or data from previous workflow Actions/steps" LABEL "com.github.actions.icon"="hash" LABEL "com.github.actions.color"="purple" Dockerfile Properties *Any* Docker image can be used! Specific GitHub labels:

Slide 13

Slide 13 text

https://github.com/marketplace/actions/slack-bot-action

Slide 14

Slide 14 text

DevOps Thames Valley/GitHub GitHub Actions Other Points Actions can be customised with args Various environment variables provided The code can be anything that runs in a Docker image It’s not just CI! Actions is about the whole development process

Slide 15

Slide 15 text

DevOps Thames Valley/GitHub GitHub Actions •Official Documentation: https://developer.github.com/actions/ •Actionable Actions workshop: http://bit.ly/actionable-actions •The life of a GitHub Action: https://blog.jessfraz.com/post/the-life-of- a-github-action/ •GitHub provided Utilities: https://github.com/actions/bin Resources

Slide 16

Slide 16 text

DevOps Thames Valley/GitHub GitHub Actions Why Would You Use Actions?

Slide 17

Slide 17 text

GitHub Actions DevOps Thames Valley/GitHub Automate Chores • Code Quality/Review - Linting and schema validation - Merge on approved PRs - Scanning for secrets • Dependency Management - Check licensing of dependencies • Project Management - Move cards in project boards - Automatically label PRs and Issues

Slide 18

Slide 18 text

GitHub Actions DevOps Thames Valley/GitHub Keeping Up-to-Date • General messaging - The usual suspects: Slack, SMS, Facebook Messenger, Telegram, … • Monitoring - And then send messaging using the above! • Release notes and changelog generation • Broadcast: Tweet, Email, …

Slide 19

Slide 19 text

GitHub Actions DevOps Thames Valley/GitHub Continuous Integration • Testing - Test suites - Code coverage • Publishing/Releasing - GPR, npm, Rubygems, Docker, … - GitHub Release • Deploying - Azure, AWS, Google Cloud, Heroku - Own servers via rsync, ssh, scp - Websites e.g. GitHub Pages, Jekyll, Netlify, Gatsby