• Stars
    star
    312
  • Rank 129,135 (Top 3 %)
  • Language
    Ruby
  • License
    MIT License
  • Created almost 4 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This action can be used to halt any workflow until required checks for a given ref (e.g., in a sibling workflow) pass successfully.

Wait On Check Action

![RSpec Tests][rspec_shield]

Pause a workflow until a job in another workflow completes successfully.

This action uses the [Checks API][checks_api] to poll for check results. On success, the action exit allowing the workflow resume. Otherwise, the action will exit with status code 1 and fail the whole workflow.

This is a workaround to GitHub's limitation of non-interdependent workflows ๐ŸŽ‰

You can run your workflows in parallel and pause a job until a job in another workflow completes successfully.

Minimal example

name: Test

on: [push]

jobs:
  test:
    name: Run tests
    runs-on: ubuntu-latest
      steps:
        ...
name: Publish

on: [push]

jobs:
  publish:
    name: Publish the package
    runs-on: ubuntu-latest
    steps:
      - name: Wait for tests to succeed
        uses: lewagon/[email protected]
        with:
          ref: ${{ github.ref }}
          check-name: 'Run tests'
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          wait-interval: 10
      ...

GHE Support

For GHE support you just need to pass in api-endpoint as an input.

name: Publish

on: [push]

jobs:
  publish:
    name: Publish the package
    runs-on: ubuntu-latest
    steps:
      - name: Wait for tests to succeed
        uses: lewagon/[email protected]
        with:
          ref: ${{ github.ref }}
          check-name: 'Run tests'
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          api-endpoint: YOUR_GHE_API_BASE_URL # Fed to https://octokit.github.io/octokit.rb/Octokit/Configurable.html#api_endpoint-instance_method
      ...

Alternatives

If you can keep the dependent jobs in a single workflow:

name: Test and publish

on: [push]

jobs:
  test:
    runs-on: ubuntu-latest
    steps: ...

  publish:
    runs-on: ubuntu-latest
    needs: test
    steps: ...

If you can run dependent jobs in a separate workflows in series:

name: Publish

on:
  workflow_run:
    workflows: ['Test']
    types:
      - completed

A real-world scenario

  • Pushes to master trigger a test job to be run against the application code.

  • Pushes to master also trigger a webhook that builds an image on external service such as Quay.

  • Once an image is built, a repository_dispatch hook is triggered from a third-party service. This triggers a deploy job.

  • We don't want the deploy job to start until the master branch passes its test job.

name: Trigger deployment on external event

on:
  # https://github.com/lewagon/quay-github-actions-dispatch
  repository_dispatch:
    types: [build_success]

jobs:
  deploy:
    if: startsWith(github.sha, github.event.client_payload.text)
    name: Deploy a new image
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Wait for tests to succeed
        uses: lewagon/[email protected]
        with:
          ref: master
          check-name: test
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          wait-interval: 20

      - name: Save the DigitalOcean kubeconfig
        uses: digitalocean/action-doctl@master
        env:
          DIGITALOCEAN_ACCESS_TOKEN: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
        with:
          args: kubernetes cluster kubeconfig show my-cluster > $GITHUB_WORKSPACE/.kubeconfig

      - name: Upgrade/install chart
        run: export KUBECONFIG=$GITHUB_WORKSPACE/.kubeconfig && make deploy latest_sha=$(echo $GITHUB_SHA | head -c7)}}

Parameters

Check name

Check name goes according to the jobs.<job_id>.name parameter.

In this case the job's name is 'test':

jobs:
  test:
    runs-on: ubuntu-latest
      steps:
      ...

In this case the name is 'Run tests':

jobs:
  test:
    name: Run tests
    runs-on: ubuntu-latest
      steps:
      ...

In this case the names will be:

  • Run tests (3.6)

  • Run tests (3.7)

jobs:
  test:
    name: Run tests
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python: [3.6, 3.7]

To inspect the names as they appear to the API:

curl -u username:$token \
https://api.github.com/repos/OWNER/REPO/commits/REF/check-runs \
-H 'Accept: application/vnd.github.antiope-preview+json' | jq '[.check_runs[].name]'

Running workflow name

If you would like to wait for all other checks to complete you may set running-workflow-name to the name of the current job and not set a check-name parameter.

name: Publish

on: [push]

jobs:
  publish:
    name: Publish the package
    runs-on: ubuntu-latest
    steps:
      - name: Wait for other checks to succeed
        uses: lewagon/[email protected]
        with:
          ref: ${{ github.ref }}
          running-workflow-name: 'Publish the package'
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          wait-interval: 10
      ...

Using running workflow name in reusable workflows

Using this action in a reusable workflow means accepting a constraint that all calling jobs will have the same name. For example, all calling workflows must call their jobs caller (or some more relevant constant) so that if the reused workflow containing the job that uses this action to wait is called callee then the task can successfully wait on caller / callee. Working example follows.

.github/workflows/caller.yml

on:
  push:
jobs:
  caller:
    uses: ./.github/workflows/callee.yml

.github/workflows/callee.yml

on:
  workflow_call:
jobs:
  callee:
    runs-on: ubuntu-latest
    steps:
      - name: Wait for Other Workflows
        uses: lewagon/[email protected]
        with:
          ref: ${{ github.ref }}
          running-workflow-name: 'caller / callee'
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          wait-interval: 10

Allowed conclusions

By default, checks that conclude with either success or skipped are allowed, and anything else is not. You may configure this with the allowed-conclusions option, which is a comma-separated list of conclusions.

name: Publish

on: [push]

jobs:
  publish:
    name: Publish the package
    runs-on: ubuntu-latest
    steps:
      - name: Wait for tests to succeed
        uses: lewagon/[email protected]
        with:
          ref: ${{ github.ref }}
          check-name: 'Run tests'
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          wait-interval: 10
          allowed-conclusions: success,skipped,cancelled
      ...

Using check-regexp

Similar to the check-name parameter, this filters the checks to be waited but using a Regular Expression (aka regexp) to match the check name (jobs.<job_id>.name)

Example of use:

name: Wait using check-regexp
on:
  push:

jobs:
  wait-for-check-regexp:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Wait on tests
        uses: ./
        with:
          ref: ${{ github.sha }}
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          running-workflow-name: wait-for-check-regexp
          check-regexp: .?-task

Wait interval (optional, default: 10)

As it could be seen in many examples, there's a parameter wait-interval, and sets a time in seconds to be waited between requests to the GitHub API. The default time is 10 seconds.

Verbose (optional, default: true)

If true, it prints some logs to help understanding the process (checks found, filtered, conclussions, etc.)

Auto-pagination

Since we are using Octokit for using GitHub API, we are subject to their limitations. One of them is the pagination max size: if we have more than 100 workflows running, the auto-pagination won't help. More about Octokit auto-pagination can be found here The solution would be to fetch all pages to gather all running workflows if they're more than 100, but it's still no implemented.

Tests

There are sample workflows in the .github/workflows directory. Two of them are logging tasks to emulate real-world actions being executed that have to be waited. The important workflows are the ones that use the wait-on-check-action.

A workflow named "wait_omitting-check-name" waits for the two simple-tasks, while the one named "wait_using_check-name" only waits for "simple-task".

More Repositories

1

dotfiles

Default configuration for Le Wagon's students
Shell
18,480
star
2

setup

Setup instructions for Le Wagon's students on their first day of Web Development Bootcamp
Ruby
17,095
star
3

data-setup

Setup instructions for Le Wagon's students on their first day of Data Science Bootcamp
Ruby
1,769
star
4

rails-templates

Jump start your Rails development with Le Wagon best practices
Ruby
644
star
5

rails-k8s-demo

[ABANDONED] Easy Rails on Kubernetes approach for Digital Ocean and a classic Rails stack: Puma, Redis, Sidekiq, Postgres, Action Cable, Webpacker. Helm 3 in production and docker-compose + dip (https://github.com/bibendi/dip) in development. Issues and PRs welcome.
Ruby
314
star
6

data-kit

Devenez Data-Scientist sur Le Wagon On Demand
Jupyter Notebook
204
star
7

rails-stylesheets

Stylesheets starting kit @LeWagon
SCSS
173
star
8

foot_traffic

[NOT MAINTAINED] Pure Ruby DSL for Chrome scripting based on Ferrum. No Selenium required. Works from any script. Simulate web app usage scenarios in production or locally.
Ruby
133
star
9

html-css-challenges

HTML / CSS challenges @LeWagon
CSS
110
star
10

bootstrap-boilerplate

A nice Bootstrap HTML boilerplate using official Bootstrap CDN to start coding right away!
HTML
109
star
11

awesome-navbars

navbar HTML/SCSS templates for Le Wagon's students
HTML
60
star
12

react-boilerplate

JavaScript
48
star
13

webpack-boilerplate

JavaScript
43
star
14

ruby-101

42
star
15

google-place-autocomplete

Exemple of Google Place Autocomplete Javascript API
HTML
40
star
16

ruby-101-challenges

Le Wagon Ruby Workshop
Ruby
38
star
17

wagon_rails

[DEPRECATED] Please use this ๐Ÿ‘‰
Ruby
37
star
18

data-templates

Curated templates for data analysis / science
Jupyter Notebook
36
star
19

goodbye-jquery

IE lost the Browser war, time to move on. Thank you for your service jQuery ๐Ÿ™
27
star
20

middleman-template

A Middleman template following @lewagon's best practices
Ruby
26
star
21

layouts-101

HTML
22
star
22

google-maps-autocomplete

Demo of Google Maps Autocomplete
Ruby
19
star
23

flats-boilerplate

17
star
24

rails-google-maps

Demo app integrating gmaps on a Flat model for Le Wagon's students.
Ruby
16
star
25

middleman-boilerplate

Middleman Boilerplate for @LeWagon Bootcamp
CSS
16
star
26

data-analytics-sprint

Jupyter Notebook
15
star
27

frontend-advanced-boilerplate

Advanced Middleman boilerplate for Le Wagon fullstack students
Ruby
14
star
28

www-sinatra

Old version of www.lewagon.com - Retired on Oct 22nd, 2015
CSS
13
star
29

rails-kickoff

[DEPRECATED] See lewagon/rails-templates ๐Ÿ‘‰
12
star
30

surfcamp

Code & Surf Camp - Septembre 2014 - France
CSS
12
star
31

nightmare-boilerplate

JavaScript
11
star
32

seatrain

[ABANDONED] Developer-friendly DevOps/GitOps boilerplate generator for Rails applications. Sets up local Docker dev environment and generates Helm chart to deploy to Digital Ocean Kubernetes. No admin black-belt required!
Ruby
10
star
33

wagon-chat-api

Wagon chat API for challenge @LeWagon
Ruby
9
star
34

redux-boilerplate

JavaScript
9
star
35

nbresult

Testing Library for Jupyter Notebooks
Python
8
star
36

ux-ui-lectures

8
star
37

install-rails

๐Ÿ‡ซ๐Ÿ‡ท Installer Rails 5 (OSX => natif, Windows => Cloud 9)
8
star
38

product-design

7
star
39

data-engineering-setup

Ruby
7
star
40

quay-github-actions-dispatch

A missing *secure* link between Quay.io build triggers and Github Action's repository_dispatch events
Go
7
star
41

ui-components

[DEPRECATED] Replaced by Le Wagon UI Kit
HTML
6
star
42

taxi-fare-interface

JavaScript
6
star
43

omniauth-kitt

OAuth Strategy for Kitt
Ruby
6
star
44

garage-api

API for React+Redux Garage (repair shop) and cars ๐Ÿš—
Ruby
6
star
45

components-demo

HTML
6
star
46

recommendation-graphdb

Python
6
star
47

python-scraping-workshop

Jupyter Notebook
6
star
48

xbar

Ruby
5
star
49

recipes

Stable website to be scraped by @lewagon students
Ruby
5
star
50

chat-redux

JavaScript
5
star
51

google-maps-markers-static

Static example of Google Maps markers (with infowindows)
HTML
5
star
52

rails-garden-manager

Ruby
5
star
53

redux-router-boilerplate

React + Redux + Router boilerplate
JavaScript
5
star
54

wagon-hunt

Ruby
5
star
55

google-maps-snazzy-themes

Snazzy Maps theme for Gmaps
5
star
56

opengraph

Moved to
Ruby
5
star
57

tips

Sharing tips with your classmates and future alumni
5
star
58

dictionary-api

Ruby
5
star
59

conduct

Le Wagon's code of conduct for the Alumni Slack & Events
4
star
60

static-airbnb-redux

JavaScript
4
star
61

pg_bucket_import

[ABANDONED]
Ruby
4
star
62

python-101

Python
4
star
63

dribbble-cards

HTML
4
star
64

fullstack-images

Images for Le Wagon fullstack challenges
4
star
65

rails-watch-list

Ruby
4
star
66

amsterdam-drive-in

Le Wagon Amsterdam - Drive-in (students project)
HTML
4
star
67

install-middleman

๐Ÿ‡ซ๐Ÿ‡ท Comment installer Middleman sur Mac ou Windows
3
star
68

wikinimous

Simple anonymous Wiki with Rails
Ruby
3
star
69

chat-rails-redux

Ruby
3
star
70

blog-redux

JavaScript
3
star
71

matplotlib

Matplotlib examples for Le Wagon's Data Science bootcamp
Jupyter Notebook
3
star
72

html-demo

HTML
3
star
73

html-css-sprint

Simple HTML/CSS Boilerplate for Le Wagon's course
HTML
3
star
74

jekyll-boilerplate

The simplest Jekyll boilerplate possible with Bootstrap + FontAwesome CDN
Shell
3
star
75

git-101-boilerplate

Simple boilerplate to show how to use git with Github on @lewagon setup day.
HTML
3
star
76

amsterdam

Le Wagon Amsterdam - BSSA
CSS
3
star
77

react-giphy

JavaScript
3
star
78

alfred-coworker

Automatically check-in people on Cobot as they connect to the Unifi Wifi
Ruby
3
star
79

cetetejecode-videos

Code prรฉsentรฉ pendant les vidรฉos du MOOC
CSS
2
star
80

active-record-advanced

Ruby
2
star
81

animation-challenges

CSS and jQuery animation challenges for on-demand
CSS
2
star
82

trello-dashboard

Starter code for a JavaScript Trello Dashboard
CSS
2
star
83

rails-base-chrome-imagemagick

Shell
2
star
84

product-design-figma

2
star
85

rails-blog

Ruby
2
star
86

bookstore

Ruby
2
star
87

garage-redux

JavaScript
2
star
88

restaurants_ajaxified_with_stimulus

Ruby
2
star
89

gosu-pong

Ruby
2
star
90

stylus

Styl.us middleman project @LeWagon
HTML
2
star
91

ml-api

Python
2
star
92

watchlist

Sampe rails app demonstrating Devise, S3, Mandrill & Sidekiq usage
Ruby
2
star
93

ecommerce-template

HTML
2
star
94

jekyll-iceme

Exemple of using Jekyll. Check out the branches for steps
CSS
2
star
95

react-flats

JavaScript
2
star
96

taxi-fare-deep

Packaged neural network-based predictor for the Kaggle's NY Taxi Fare challenge
Jupyter Notebook
2
star
97

krails

[ABANDONED]
Ruby
2
star
98

fullstack-challenges-04-Rails-watch-list-specs

Ruby
2
star
99

intro-to-data-science-env

Setup environment for Introduction to Data Science challenges
Python
2
star
100

taxi-fare

Python
1
star