Dependencies Between Workflows on Github Actions

前端 未结 2 1236
挽巷
挽巷 2021-01-03 21:03

I have a monorepo with two workflows:

.github/workflows/test.yml

name: test

on: [push, pull_request]

jobs:
  test-packages:
    runs-o         


        
相关标签:
2条回答
  • 2021-01-03 21:35

    Now it's possible to have dependencies between workflows on Github Actions using workflow_run.

    Using this config, the Release workflow will work when the Run Tests workflow is completed.

    name: Release
    on:
      workflow_run:
        workflows: ["Run Tests"]
        branches: [main]
        types: 
          - completed
    
    0 讨论(0)
  • 2021-01-03 21:46

    Update: It's now possible to create dependencies on workflows with workflow_run. See this answer.

    Is there a way to create a dependency between workflows?

    I don't think this is possible at the moment. Perhaps it's a feature they will add in future. Personally, I think it's more likely that a feature like CircleCI's orbs will get added to share common sections of workflows.

    For an alternative solution, does putting it all in the same workflow like the following work for you? The deploy-packages job will only execute if a tag starting with v is being pushed.

    name: my workflow
    on: [push, pull_request]
    jobs:
      test-packages:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v1
          - name: test packages
            run: echo "Running tests"
      deploy-packages:
        if: startsWith(github.ref, 'refs/tags/v')
        runs-on: ubuntu-latest
        needs: test-packages
        steps:
          - uses: actions/checkout@v1
          - name: deploy packages
            run: echo "Deploying packages"
    
    0 讨论(0)
提交回复
热议问题