act icon indicating copy to clipboard operation
act copied to clipboard

Issue: support for reusable workflows

Open catthehacker opened this issue 2 years ago • 9 comments

ref: https://github.com/github/roadmap/issues/98

GitHub is going to support reusable workflows (similar to Azure DevOps Pipelines)

How will it work? To reuse a workflow, ensure it listens to a new workflow_call event trigger, and then reference it with the familiar uses syntax. Optionally, use inputs and outputs to pass data between them, just like with actions.

For example:

name: Build & Release App

on:
  push:

jobs:
  build:
    uses: example-org/automation/workflows/build.yml@1

  release:
    needs: build
    uses: example-org/automation/workflows/release.yml@1
    with:
      artifact-url: jobs.build.outputs.artifact-url

catthehacker avatar Sep 26 '21 05:09 catthehacker

I want to add someone found the beta documentation ( source ) https://docs.github.com/en/actions/learn-github-actions/reusing-workflows

I'm going to implement it in my own actions-service (runner.server)

It seems to be even deployed as beta. Far more information than in the roadmap.

EDIT 2021/10/28: For reusable workflows it might be useful to backport the following commit https://github.com/ChristopherHX/act/commit/efdc2fa17528a643addc00009a2299d2f514da6d after my PR uses in composite is merged

EDIT 2022/03/28 The commit mentioned in the previous edit has been merged via the uses in composite and is already in v0.2.26. This issue has a low priority for me. DONE:

  • make inputs context available in the runcontext

TODO:

  • obtain the reusable workflows in the planner
  • evaluate the inputs and secrets
  • only make evaluated secrets available in the reusable workflow
  • assign the evaluated inputs to the runcontext of the reusable workflow
  • evaluate workflow outputs and add the jobs context, the same as needs of a job which depends on all other jobs in the reusable workflow

ChristopherHX avatar Sep 30 '21 15:09 ChristopherHX

We just started implementing reusable workflows. As I was going through the pains of several commits and merges leading to broken workflows I came across this repo! It was linked in the recent Thoughtworks Technology Radar. Anyways just here to say I'm looking forward to using it !!

brettcurtis avatar Oct 27 '21 14:10 brettcurtis

https://github.blog/changelog/2021-11-24-github-actions-reusable-workflows-are-generally-available/

catthehacker avatar Dec 04 '21 08:12 catthehacker

News?

I received an error when trying to use a reusable workflow by act:

ERRO[0000] 'runs-on' key not defined in Terraform Plan - Github Actions Runner/production 
ERRO[0000] 'runs-on' key not defined in Terraform Plan - Github Actions Runner/production 
ERRO[0000] 'runs-on' key not defined in Terraform Plan - Github Actions Runner/production 

alexsanderp avatar Dec 22 '21 01:12 alexsanderp

That's because they are not supported

catthehacker avatar Dec 22 '21 04:12 catthehacker

Hi, I also get the following when trying to run a job that uses a reusable workflow:

time="2022-01-19T14:19:37+01:00" level=error msg="'runs-on' key not defined in <workflow_name to test>/<job_name>"
time="2022-01-19T14:19:37+01:00" level=error msg="'runs-on' key not defined in <workflow_name to test>/<job_name>"
time="2022-01-19T14:19:37+01:00" level=error msg="'runs-on' key not defined in <workflow_name to test>/<job_name>"

Any plans on implementing support for reusable workflows?

kjbrak avatar Jan 19 '22 13:01 kjbrak

Hi, just wondering if support for reusable workflows is on the backlog for act? As I've started refactoring my workflows to support them, I found that unfortunately it broke my ability to use act for unit testing.

larryclaman avatar Feb 11 '22 18:02 larryclaman

Hi, just wondering if support for reusable workflows is on the backlog for act?

Yes, that's why this issue is opened

--- EDIT ---

Issue is locked because none of recent responses are helpful at all. Please familiarise yourself with https://github.com/golang/go/wiki/NoPlusOne/ In case of this, we are aware of the reusable workflows (I raised the issue after all). If there will be any news regarding this issue, it will be updated and/or unlocked. If there will be an attempt at implementing it, its pull request will be linked. (Please feel free to contribute it) Please do not ask when is this going to be implemented. It's annoying and doesn't contribute at all.

catthehacker avatar Feb 11 '22 18:02 catthehacker

Any Update?

lionslair avatar Feb 28 '22 07:02 lionslair