42 lines
1.5 KiB
YAML
42 lines
1.5 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 '\\\{' | 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 $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
|