Inject CI workflows before pushing new tags
All checks were successful
/ Test on tags (push) Successful in 16s

This commit is contained in:
Antoine Martin 2024-09-09 17:02:09 -04:00
parent 6374271565
commit 5733b4e0cf
Signed by: forge
GPG key ID: D62A472A4AA7D541

View file

@ -4,35 +4,39 @@ on:
schedule: schedule:
- cron: '@hourly' - cron: '@hourly'
push:
branches:
- 'master'
jobs: jobs:
mirror: mirror:
name: Pull from upstream name: Pull from upstream
runs-on: x86_64 runs-on: x86_64
container: container:
image: 'docker.io/node:20-bookworm' 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: 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: | run: |
git init --bare . git init --bare .
git remote add origin https://git.joeyh.name/git/git-annex.git git remote add origin $upstream
git fetch origin refs/heads/master:refs/mirror/master while read tag; do
git ls-remote origin refs/heads/v*/master | while read sha full_ref ; do git fetch origin tag $tag --no-tags
ref=${full_ref#refs/heads/} done < missing_tags
git fetch origin $full_ref:refs/mirror/$ref - name: Injecting packaging workflow
tag=${ref%/master} run: |
git fetch origin refs/tags/${tag}*:refs/mirror-tags/${tag}* while read tag; do
done git checkout $tag
if test "${{ vars.TEST }}" != true ; then git tag -d $tag
token=${{ secrets.CODE_FORGEJO_TOKEN }} git checkout ci -- ./forgejo
destination=${{ vars.DESTINATION }} git commit -m 'Inject custom workflow'
owner=${{ vars.OWNER }} git tag -a $tag -m $tag
else done < missing_tags
token=${{ secrets.TEST_FORGEJO_TOKEN }} - name: Pushing patched tags
destination=${{ vars.TEST_DESTINATION }} run: git push --force https://any:$token@$destination refs/tags/*:refs/tags/* --tags
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