48 lines
1.6 KiB
YAML
48 lines
1.6 KiB
YAML
on:
|
|
workflow_dispatch:
|
|
|
|
schedule:
|
|
- cron: '@hourly'
|
|
|
|
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: ${{ github.server_url }}/${{ github.repository }}
|
|
tags: '10.2024*'
|
|
token: ${{ secrets.CODE_FORGEJO_TOKEN }}
|
|
owner: ${{ vars.OWNER }}
|
|
steps:
|
|
- name: Comparing tags of upstream and destination
|
|
run: |
|
|
git ls-remote $upstream "refs/tags/$tags" | grep -v '{' | sed 's|.*/||' > upstream_tags
|
|
git ls-remote $destination "refs/tags/$tags" | grep -v '{' | sed 's|.*/||' > destination_tags
|
|
cat upstream_tags destination_tags | tr ' ' '\n' | sort | uniq -u | tr '\n' '\t' > missing_tags
|
|
echo "Upstream tags:"
|
|
cat upstream_tags
|
|
echo "Destination tags:"
|
|
cat destination_tags
|
|
echo "Missing tags:"
|
|
cat missing_tags
|
|
- name: Fetching missing tags
|
|
run: |
|
|
git init --bare .
|
|
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
|