Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions...

32
Open Source CI/CD components for GitHub Actions FossAsia Summit Lothar Schulz 2020 03 19 pic: © moovel Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz

Transcript of Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions...

Page 1: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

Open Source CI/CD components for GitHub Actions

FossAsia Summit

Lothar Schulz2020 03 19

pic: © moovel

Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz

Page 2: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

pic: © moovel

Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz

Page 3: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

pic: © moovel

Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz

Page 4: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

Engineering Manager

lotharschulz.info

CI/CD Meetup Berlin

github.com/lotharschulz

speakerdeck.com/lothar

@lothar_schulz

lnkd.in/lotharschulz

Me

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

Page 5: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

GitHub Actions

Workflow Automation

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

Page 6: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

Built-in CI/CDGitHub Actions

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

Page 7: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

What are GitHub Actions?

With GitHub Actions, workflows and steps are just code in a repository, so you can create, share, reuse, and fork your software development practices.

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

https://github.blog/2019-08-08-github-actions-now-supports-ci-cd/

Page 8: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

Page 9: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

Open Source

pic: © moovel

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

Page 10: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

github.com/actions

Page 11: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

github.com/sdras/awesome-actions#community-resources

Page 12: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

Page 13: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

github.com/jessfraz/shaking-finger-action

Page 14: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

Open Source Projects using GitHub actions (list not complete)

• https://github.com/gatsbyjs/gatsby/tree/master/.github/workflows• https://github.com/hakimel/reveal.js/blob/master/.github/workflows/js.yml• https://github.com/twbs/bootstrap/blob/master/.github/workflows/test.yml• https://github.com/microsoft/vscode/tree/master/.github/workflows• https://github.com/facebook/create-react-app/tree/master/.github/workflows• https://github.com/hakimel/reveal.js/blob/master/.github/workflows/js.yml• https://github.com/babel/babel/tree/master/.github/workflows• https://github.com/nodejs/node/tree/master/.github/workflows• https://github.com/microsoft/TypeScript/tree/master/.github/workflows

Page 15: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

How To's

pic: © moovel

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

Page 16: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

Matrix - Builds on Linux, macOS, Windows

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

strategy: fail-fast: false matrix: os: [macOS-10.14, ubuntu-18.04] goos: [linux, darwin] exclude: - os: macOS-10.14 goos: linux - os: ubuntu-18.04 goos: darwin runs-on: ${{ matrix.os }}

Page 17: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

Matrix - Excludes

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

strategy: fail-fast: false matrix: os: [macOS-10.14, ubuntu-18.04] goos: [linux, darwin] exclude: - os: macOS-10.14 goos: linux - os: ubuntu-18.04 goos: darwin runs-on: ${{ matrix.os }}

exclude: - os: macOS-10.14 goos: linux - os: ubuntu-18.04 goos: darwin

Page 18: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

Matrix - Includes & Excludes

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

strategy: fail-fast: false matrix: os: [macOS-10.14, ubuntu-18.04] goos: [linux, darwin] exclude: - os: macOS-10.14 goos: linux - os: ubuntu-18.04 goos: darwin runs-on: ${{ matrix.os }}

exclude: - os: macOS-10.14 goos: linux - os: ubuntu-18.04 goos: darwin

include: - os: macOS-10.14 goos: darwin - os: ubuntu-18.04 goos: linux

Page 19: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

Matrix - Includes & Excludes

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

strategy: fail-fast: false matrix: os: [macOS-10.14, ubuntu-18.04] goos: [linux, darwin] exclude: - os: macOS-10.14 goos: linux - os: ubuntu-18.04 goos: darwin runs-on: ${{ matrix.os }}

exclude: - os: macOS-10.14 goos: linux - os: ubuntu-18.04 goos: darwin

include: - os: macOS-10.14 goos: darwin - os: ubuntu-18.04 goos: linux !

Page 20: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

Jobs

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

Jobs can run at the same time in parallel or be dependent on the status of a previous job and run sequentially.

build-and-dockerhub-push-if-linux: needs: [benchmark, test]

Page 21: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

Conditionals

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

if: matrix.os == 'ubuntu-18.04' env: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} run: | d=$(date +%Y-%m-%d) tag=$d-${{ matrix.os }}-${{ github.sha }} docker build -t lotharschulz/hello-github-actions:$tag . docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD} docker push lotharschulz/hello-github-actions:$tag

Page 22: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

Matrix

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

Page 23: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

Matrix

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

Page 24: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

Matrix

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

Page 25: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

Surprises

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

test: runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v1 - uses: actions/setup-java@v1 with: java-version: 11 - uses: eskatos/gradle-command-action@v1 with: arguments: test - name: test the code

Page 26: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

Fix

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

test: runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v1 - uses: actions/setup-java@v1 with: java-version: 11 - uses: eskatos/gradle-command-action@v1 with: arguments: test# - name: test the code

Page 27: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

Page 28: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

Demo Code

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

Page 31: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

pic: © moovel

THANK YOU

Page 32: Open Source CI/CD components for GitHub Actions · Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz Open Source Projects

@lothar_schulzOpen Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19

pic: © moovel

THANK YOU

SLIDE DECK

Open Source CI/CD components for GitHub Actions | FossAsia Summit | Lothar Schulz | 2020 03 19 @lothar_schulz

pic: © moovel