Reputation: 339
I have two repositories A and B, both hosted on GitHub.
They have to stay separate. I want to rebuild repo A, each time repo B receives an update. It has to work using GitHub Actions only. I'd prefer if repo B would stay action-less, i.e. no CI/CD attached to that repo (I want it to store only files). I was thinking maybe I can make it work using git submodules? Repo B would be a submodule within Repo A. Is it possible to build GH action within repo A, to detect changes in repo B and pull from there?
edit: Repo A is Static-site generator(nextjs
) I'm intending to share with public. Repo B is full of text files(org-roam
) which a user brings with themselves. Together they build a personal wiki website. I'd want to minimize the configuration hassle - that's why I want to have all CI/CD and code encapsulated in Repo A, so the user could just fork it, and plug-and-play it with their knowledge base repository (repo B). Having intertwined GitHub Actions between two repositories seems not ideal - that's why I'm searching for better solution
Upvotes: 1
Views: 2315
Reputation: 20551
It seems it is OK to have this update in a daily interval. Therefore, depdendabot can be a solution:
.github/dependabot.yml
:
version: 2
updates:
- package-ecosystem: "gitsubmodule"
directory: "/"
schedule:
interval: daily
With an automerge, this gets in:
name: Auto Merge
on: [pull_request_target,]
permissions:
contents: write
pull-requests: write
jobs:
automerge:
runs-on: ubuntu-latest
if: (github.actor == 'dependabot[bot]')
steps:
- name: Merge PR
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GH_TOKEN_GH_PR_MERGE}}
The user needs to create the secret GH_TOKEN_GH_PR_MERGE
. With some personal access token with the "right" rights. (The discussion at https://github.com/cli/cli/issues/8352#issuecomment-1850344748 did not quite say which rights are correct).
Upvotes: 0
Reputation: 339
thanks to @GuiFalourd and @riQQ , I was able to put together proof-of-concept set of repositories
Both repo share same GitHub Personal Access Token. To fill the blanks from the blog.marcnuri.com guide, here is minimal set of permissions required to make this work (given both repositories are public, otherwise you need repo
permission:
Upvotes: 1