Skip to content

Commit

Permalink
feat: auto sync forked actions repos
Browse files Browse the repository at this point in the history
reduce maintenance toil on the ops team
  • Loading branch information
Mossman1215 committed Nov 23, 2023
1 parent 8e93f9b commit 4b2e7c0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/sync-actions-forks.yml
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
4 changes: 4 additions & 0 deletions hack/update-forks.sh
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"

0 comments on commit 4b2e7c0

Please sign in to comment.