DEV Community

sumandari
sumandari

Posted on • Edited on

1

GithubAction -- use a workflow from another workflow

It's called reusable workflow.

I have a workflow for test, and I have another workflow for release. Everytime I release a version, I want to have test passed before run release jobs.

What I have to do is to add workflow_call on my workflow

# ci.yaml
name: ci-build-and-test

on:
  push:
    branches:
      - main
  pull_request:
  workflow_call:

jobs:
  - (steps to checkout, setup dependency and run test)

Enter fullscreen mode Exit fullscreen mode

then I can call it manually from another workflow (yaml file) by using uses and path to the ci.yaml file.
If you're using the reusable workflow from different repository then you need to add your github organisation and repo name.

# cd.yaml
name: cd-build-and-publish

on:
  release:
    types:
      - released

jobs:
  compliance:
    if: github.event.release.target_commitish == 'main'
    uses: ./.github/workflows/ci.yaml

Enter fullscreen mode Exit fullscreen mode

see more at:
https://github.blog/2022-02-10-using-reusable-workflows-github-actions/

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay