From a48a37c28945f73c549911a4e8beefdf0199d25b Mon Sep 17 00:00:00 2001 From: Aaron Dalton Date: Thu, 18 Jan 2024 20:13:29 -0800 Subject: [PATCH] Fix fork-sync --- .github/workflows/fork-sync.yml | 46 ++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/.github/workflows/fork-sync.yml b/.github/workflows/fork-sync.yml index 5f275892..a56c2915 100644 --- a/.github/workflows/fork-sync.yml +++ b/.github/workflows/fork-sync.yml @@ -1,5 +1,11 @@ on: workflow_dispatch: + inputs: + tags: + description: 'tag list' + type: string + required: false + default: '' schedule: - cron: '2 */12 * * *' @@ -7,7 +13,41 @@ jobs: synchronize-upstream: runs-on: ubuntu-latest steps: - - run: gh repo sync discretizer/homepage - env: - GH_TOKEN: ${{ github.token }} + - name: Fetch Upstream Tags + id: fetch-upstream-tags + if: ${{ !inputs.tags }} + run: | + gh repo clone dicretizer/homepage && cd homepage + git fetch --tags + fmt=' + r=%(refname) + echo ${r#refs/tags/} + ' + echo 'NEW_TAGS<> $GITHUB_OUTPUT + $(eval `git for-each-ref --format=$fmt --no-merge upstream refs/tags`) >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + - name: Bump Current + run: | + git checkout upstream + git merge upstream/master upstream + - name: Create Tags + if: ${{inputs.tags || steps.fetch-upstream-tags.outputs.NEW_TAGS}} + run: | + for TAG in ${NEW_TAGS}; do + git checkout -b release/${TAG} ${TAG} + git rev-list --no-merges --reverse origin/feature/add_auth ^upstream | git cherry-pick --stdin + git rev-list --no-merges --reverse origin/fork/automation ^upstream -- .github/**| git cherry-pick --stdin + git tag ${TAG} release/${TAG} + done + for TAG in ${NEW_TAGS}; do git push -u origin release/${TAG} ${TAG}; done + env: + NEW_TAGS: ${{inputs.tags || steps.fetch-upstream-tags.outputs.NEW_TAGS}} + - name: Push Current + run: | + git rev-list --no-merges --reverse origin/feature/add_auth ^upstream | git cherry-pick --stdin + git rev-list --no-merges --reverse origin/fork/automation ^upstream -- .github/**| git cherry-pick --stdin + git push upstream release/current + env: + GH_TOKEN: ${{ github.token }} +