Basic deployment testing

Does it make sense to do something like:

echo "::set-output name=url::https://example.com" in say my .github/workflows/deploy.yml and then have another .github/workflows/test.yml that looks like:

name: Sanity test
on:
  workflow_run:
    workflows: ["Deploy"]
    types:
      - completed
jobs:
  lighthouse:
    runs-on: ubuntu-latest
    steps:
      - run: curl -f ${{ inputs.url }}

Struggling to find other people’s workflows that do this!

Obviously if this fails… next thing to consider is… a roll back? I wonder how that works!

That is not possible. The workflow commands (such as set-output) are used to communicate with the runner machine to set environment variables and output values. The outputs of these commands are limited to the job they are run in. For example, set-output sets the output of a specific step. Only steps defined in the same job will be able to read this output as these commands are run on the same runner. This runner is cleaned up once your job finishes. There is thus no way to pass these values to another workflow.

The workflow_run event runs when another workflow completes and will not include any outputs that may have been generated by the previous workflow’s steps.

You can inspect what context the workflow_run will have (on the github.event object) from the docs below:

This seems like it’d be better suited to multiple jobs in one workflow file. In that case you can use jobs.<job_id>.needs to define dependencies between jobs, and communicate values from one job to another using jobs.<job_id>.outputs.