Contents

Trigger Github Action Workflow by another Workflow from a Different Github Repository

In some cases, we might want to trigger github action workflow pipeline without interacting with the repository directly (trigger on push or manual trigger). For example, hiding Github Pages source code without any subscription.

Abstract
This is a workaround article based on my needs to hide a github page source code from public. The right solution for this problem is to deploy github page from private repo, but this solution require subscription.

Generate Personal Access Token (PAT)

Go to Your Profile Settings

After loged in to your Github account, Click on your profile picture (right top corner), then click “Settings”.

/trigger-another-workflow-from-another-repo-in-github-action/images/profile-settings.png
Profile Setting

Open Developer Settings

On the left pane, scroll down untill you found “Developer Setting”.

/trigger-another-workflow-from-another-repo-in-github-action/images/developer-settings.png
Developer Setting

Generate Your Token

On the left pane, click on “Personal Access Token”, it will show a dropdown list, chose “Fine-grained tokens”.

Tip
Even though it’s still in beta, it’s UI is better than the classic one.

/trigger-another-workflow-from-another-repo-in-github-action/images/generate-pat.png
Generate PAT

Configure the Token

Do as what I’ve marked on the image below.

/trigger-another-workflow-from-another-repo-in-github-action/images/configure-pat.png
Configure PAT

Info
“Fine-grained tokens” expiration date can not be set to never, I have workaround for this, to automate Github Action Secret update on multiple terget repo. I will make separate article, so stay tuned.

PAT has been Generated

Copy and save your PAT.

/trigger-another-workflow-from-another-repo-in-github-action/images/pat-generated.png
PAT Generated

Create Github Action Secret on the Triggering Workflow

Go to your triggering workflow, and create the secret there.

Repo Settings

Open settings in the triggering repo.

/trigger-another-workflow-from-another-repo-in-github-action/images/repo-settings.png
Repo Settings

New Repo Secret

On the left pane, scroll down untill you found “Secrets”, then click it, and dropdown list will shown, then click “Actions”, click “New Repository Secret”.

/trigger-another-workflow-from-another-repo-in-github-action/images/repo-secret.png
Repo Secret

Create Secret

Enter name “GH_PAT” as the name, and paste the PAT you’ve created before in the secret form, click “add Secret”

/trigger-another-workflow-from-another-repo-in-github-action/images/new-secret.png
New Secret

Secret Created

Now the secret should be created.

/trigger-another-workflow-from-another-repo-in-github-action/images/secret-created.png
Secret Created

Create New Workflow File

Create workflow file to Trigger another Workflow on a Repo that You Want to Run the Trigger.

Copy and paste this yaml file example.

Success
Run this workflow and you should have triggered the target workflow.
Tip

This method only trigger the workflow and then finish the pipeline with success report, whether the triggered workflow status is success or fail.

If you want confirmation and wait until the triggered workflow finished, use trigger-and-wait.

Footnote

If there is something you want to ask about this article, please don’t hesitate to raise an issue on this repo or contact me via Telegram.

Note
This article was made base on solution that I found in Github Community Discussion