diff --git a/.github/workflows/sync-actions-forks.yml b/.github/workflows/sync-actions-forks.yml new file mode 100644 index 00000000..f1cee172 --- /dev/null +++ b/.github/workflows/sync-actions-forks.yml @@ -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@b4ffde65f46336ab88eb53be808477a3936bae11 + - 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 diff --git a/hack/update-forks.sh b/hack/update-forks.sh new file mode 100755 index 00000000..03469934 --- /dev/null +++ b/hack/update-forks.sh @@ -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"