Skip to content
play

GitHub Action

cross-repo-pipeline-trigger

v1.1 Latest version

cross-repo-pipeline-trigger

play

cross-repo-pipeline-trigger

Triggers a workflow in another repository and posts results in the pull request comments

Installation

Copy and paste the following snippet into your .yml file.

              

- name: cross-repo-pipeline-trigger

uses: amandastecz/pipeline-trigger@v1.1

Learn more about this action in amandastecz/pipeline-trigger

Choose a version

Cross Repository Pipeline Trigger Action

Description

The Cross Repository Pipeline Trigger Action is a GitHub Action that allows you to initiate a workflow in a different repository (target repo) and automatically post the workflow execution results in the original repository's pull request comments.

Inputs

Required Inputs

  • pat-token: Personal Access Token (PAT) within the secrets of the repository initiating the workflow.
  • owner: Owner of the target repository where the workflow will be triggered.
  • repo: Name of the target repository where the workflow will be triggered.

Outputs

  • message: Message within the original repository containing the workflow results of the target repository.

Example Usage

Setup this yml file within the origin repository, which means the repository that wants to trigger another one:

name: Origin Repository Workflow

on:
  pull_request:
    branches:
      - main

jobs:
  cross-repo-pipeline:
    runs-on: ubuntu-latest
    steps: #here starts the action's setup
      - name: cross-repo-pipeline-trigger
        uses: amandastecz/pipeline-trigger@v1.1
        with:
          pat-token: ${{ secrets.PAT_TOKEN }} # add a secret called PAT_TOKEN
          owner: target-owner #changeme
          repo: target-repo #changeme

Inside the yml file of the target repository, please enable the "repository_dispatch" event, example:

name: Target Repository Workflow
on:
  pull_request:
    branches:
      - main
  workflow_dispatch:
  repository_dispatch: #add this
jobs:
  test: ...

E.g. Success message within PR comments: image

Secrets

This action uses the following secrets:

  • PAT_TOKEN: Personal Access Token (PAT) classic.

Personal Access Token (PAT)

  1. Create a PAT Token (classic) by following the GitHub instructions.
  2. Select the necessary scopes for the personal token:
  • repo - full control of private repositories
  • workflow - update GitHub Action workflows
  • admin:repo_hook - full control of repository hooks
  1. Add the PAT_TOKEN as a secret in the original repository. Follow the GitHub instructions.