GitHub Actions Alex Hedley

GitHub Actions

Created by Alex Hedley

Slides: https://github.com/alex-hedley/talk-githubactions

About

Automate your workflow from idea to production

GitHub Actions makes it easy to automate all your software workflows, now with world-class CI/CD. Build, test, and deploy your code right from GitHub. Make code reviews, branch management, and issue triaging work the way you want.

About

Run a workflow on any GitHub event

Kick off workflows with GitHub events like push, issue creation, or a new release. Combine and configure actions for the services you use, built and maintained by the community.

Whether you want to build a container, deploy a web service, or automate welcoming new users to your open source projects—there's an action for that. Pair GitHub Packages with Actions to simplify package management, including version updates, fast distribution with our global CDN, and dependency resolution, using your existing GITHUB_TOKEN.

YAML

name


					# Simple workflow for deploying static content to GitHub Pages
					name: Deploy static content to Pages
					

YAML

on


					on:
						# Runs on pushes targeting the default branch
						push:
						  branches: ["main"]
						  paths: src/**

						# Allows you to run this workflow manually from the Actions tab
						workflow_dispatch:
					

YAML

permissions


					# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
					permissions:
					  contents: read
					  pages: write
					  id-token: write
					

YAML

jobs


						jobs:
					

This is a list of items.

YAML

Job(s)


						# Single deploy job since we're just deploying
						deploy:
						  runs-on: ubuntu-latest
						  steps:
					

deploy: is the name of the job, change this to whatever you want.

runs-on: can be windows, linux or mac (or a custom image)

YAML

steps


						steps:
						  - name: Checkout
						    uses: actions/checkout@v3
					

These are where you can use the different GitHub Actions.

YAML

run task


						# copy index.html to 404.html to serve the same file when a file is not found
						- name: copy index.html to 404.html
						  run: cp release/wwwroot/index.html release/wwwroot/404.html
					

You can also just run a command as if you were in the terminal.

YAML

workflow_run task


					on:
						# Only trigger, when the build workflow succeeded
						workflow_run:
						  workflows: ["Build / Test (with Reports)"]
						  types:
							- completed
					

This means you can trigger a workflow job when another workflow finishes.

Todo

  • workflow_run
  • needs
  • relative files

Blog Posts

Alternatives

  • github-workflows-kt is a tool for creating GitHub Actions workflows in a type-safe script, helping you to build robust workflows for your GitHub projects without mistakes, with pleasure, in Kotlin.

Links

Any Questions ❓

Thanks 👏🏻