DEV Community

Arnob
Arnob

Posted on

GitHub Action Runs From Repository To Another Repository

Hello, Here I show you the process with run one repository action from another specific repository.

https://svrooij.io/assets/images/github-actions-banner.png

Use Case

Lots of developer work to build projects. So any project there is a GitHub workflow. So you wanted to protect the workflow for the wrong deployment.

So here is the process of running action from one repository to any other repository.

Config Token

You have to need a Personal Access Token (PAT). That token actually works when you pull another repository to the action.

Goto Settings > Developer settings > Personal access tokens (classic)

Developer settings page

Generate a token.

Token generate token

Now needed to set up the workflow.

Action:

Here is the GitHub workflow

This workflow actually works as a middleware of project deployment. This workflow defines it runs in ubuntu and then selects any repository. Done.

Select Repository

Here is the workflow from the selected repository

This workflow is the GitHub action repository. It actually acknowledges/commit the arn-ob/github-actions repository for running the arn-ob/ssr-fetch.

Note: It actually based on branch to branch.

Now hope you will get confused. How does it work? So it is better to give you a diagram of the process.

captionless image

Process Details:

1st github-repo-1 gives a commit then it runs the workflow. So repo-1 workflow yaml has targeted the repository to the github-action repo. repo-1 has committed to the github-action with a blank text file and commits that. So then github-action workflow runs. Then the github-action yaml has a repository of github-repo-1. So the action pulls the github-repo-1 code. Then it runs as it told to the github-action yaml.

Happy Learning…

Top comments (0)