Run a GitHub workflow in a specific order depending on workflow_run

Viewed 25

I have a few GitHub workflows that I use to build documentation, my site itself, and then deploy them to a Firebase project. I'm hoping to somehow optimize the order of deployment.

Setup

First, there's docs.yml with the following triggers.

name: docs

on:
  push:
    paths:
      - "cli.py"
      - "README.md"
      - "docs/source/*"
  workflow_dispatch:
  pull_request:

I want my docs to be built whenever I update the CLI, README, or anything in the source folder of my Sphinx documentation.

Then there's my Firebase deployment workflow, with the following triggers.

name: firebase deployment

'on':
  push:
    branches:
      - master
  workflow_run: 
    workflows: ["docs"]
    branches: ["master"]
    types:
      - completed
  workflow_dispatch:

Because I have two sites in the project (my actual project site, and the documentation), I want Firebase to deploy when my project updates and when my docs update (which I defined as workflow_run, to run when the docs workflow runs successfully after building my documentation).

Problem

Let's say I update cli.py. Here's what happens currently.

  1. Firebase deployment is triggered on push.
  2. Docs building is triggered on push (cli.py changed).
  3. After docs are built, Firebase deployment is triggered again (on docs workflow_run).

I'm hoping for a way to optimize this so that Firebase deployment doesn't run twice. I can't remove the first on: push trigger, because I need Firebase to deploy my main project site if something other than cli.py (or relevant doc files) changes in the repo.

Sorry for the weird one, I've been racking my brain for a while. I feel like I'm missing something obvious. Perhaps I can split up my Firebase deployment workflow into one for each site? I don't know how to do this given both sites exist under the umbrella of one project, and each site's site (trigger) is configured in the same firebase.json (root level of the repo).

Thanks in advance.

0 Answers
Related