-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: auto sync forked actions repos
reduce maintenance toil on the ops team
- Loading branch information
1 parent
8e93f9b
commit 4b2e7c0
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: sync actions forks | ||
#REQUIRES PAT WITH REPO(READ,WRITE) ORG(READ) WORKFLOWS(WRITE) | ||
permissions: | ||
contents: write | ||
on: | ||
schedule: | ||
- cron: 0 1 * * * | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
prepare: | ||
runs-on: ubuntu-latest | ||
if: ${{ startsWith(github.repository, 'GeoNet/') == false }} | ||
steps: | ||
- name: require GeoNet org | ||
run: | | ||
exit 1 | ||
sync-forks: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: sync changes | ||
id: sync-changes | ||
env: | ||
GH_TOKEN: ${{ secrets.GH_CI_USER_TOKEN }} | ||
run: | | ||
gh repo list geonet --no-archived --fork --json nameWithOwner --jq '.[].nameWithOwner' \ | ||
| xargs -I{} gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/{} --template '{{.full_name}},{{.default_branch}}{{"\n"}}' \ | ||
| xargs -I{} hack/update-forks.sh {} | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
REPO=$(echo "$1" | cut -d, -f1) | ||
BRANCH=$(echo "$1" | cut -d, -f2) | ||
gh api --method POST -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" -f branch="$BRANCH" "/repos/$REPO/merge-upstream" |