From 5733b4e0cf2dd032e0962210eebb364c3795c1c7 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 9 Sep 2024 17:02:09 -0400 Subject: [PATCH] Inject CI workflows before pushing new tags --- .forgejo/workflows/mirror-repository.yml | 50 +++++++++++++----------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/.forgejo/workflows/mirror-repository.yml b/.forgejo/workflows/mirror-repository.yml index 791fe23d0e..26c6926ae5 100644 --- a/.forgejo/workflows/mirror-repository.yml +++ b/.forgejo/workflows/mirror-repository.yml @@ -4,35 +4,39 @@ on: schedule: - cron: '@hourly' - push: - branches: - - 'master' - jobs: mirror: name: Pull from upstream runs-on: x86_64 container: image: 'docker.io/node:20-bookworm' + env: + upstream: https://git.joeyh.name/git/git-annex.git + destination: {{ vars.DESTINATION }} + tags: '10.2024*' + token: ${{ secrets.CODE_FORGEJO_TOKEN }} + owner: ${{ vars.OWNER }} steps: - - name: git mirror branches {v*/,}master & tags + - name: Comparing tags of upstream and destination + run: | + git ls-remote $upstream "refs/tags/$tags" | grep -v '\{' | awk '\{print $2\}' | sed 's|refs/tags/||' > upstream_tags + git ls-remote $destination "refs/tags/$tags" | grep -v '\{' | awk '\{print $2\}' | sed 's|refs/tags/||' > destination_tags + cat upstream_tags destination_tags | tr ' ' '\n' | sort | uniq -u | tr '\n '\t' > missing_tags + - name: Fetching missing tags run: | git init --bare . - git remote add origin https://git.joeyh.name/git/git-annex.git - git fetch origin refs/heads/master:refs/mirror/master - git ls-remote origin refs/heads/v*/master | while read sha full_ref ; do - ref=${full_ref#refs/heads/} - git fetch origin $full_ref:refs/mirror/$ref - tag=${ref%/master} - git fetch origin refs/tags/${tag}*:refs/mirror-tags/${tag}* - done - if test "${{ vars.TEST }}" != true ; then - token=${{ secrets.CODE_FORGEJO_TOKEN }} - destination=${{ vars.DESTINATION }} - owner=${{ vars.OWNER }} - else - token=${{ secrets.TEST_FORGEJO_TOKEN }} - destination=${{ vars.TEST_DESTINATION }} - owner=${{ vars.TEST_OWNER }} - fi - git push --force https://any:$token@$destination/$owner/git-annex refs/mirror/*:refs/heads/* refs/mirror-tags/*:refs/tags/* --tags + git remote add origin $upstream + while read tag; do + git fetch origin tag $tag --no-tags + done < missing_tags + - name: Injecting packaging workflow + run: | + while read tag; do + git checkout $tag + git tag -d $tag + git checkout ci -- ./forgejo + git commit -m 'Inject custom workflow' + git tag -a $tag -m $tag + done < missing_tags + - name: Pushing patched tags + run: git push --force https://any:$token@$destination refs/tags/*:refs/tags/* --tags