electron/.forgejo/workflows/mirror-repository.yml

55 lines
1.8 KiB
YAML
Raw Normal View History

2024-10-10 18:13:12 +00:00
on:
workflow_dispatch:
schedule:
- cron: '@hourly'
jobs:
mirror:
name: Pull from upstream
runs-on: x86_64
container:
image: alpine:latest
env:
upstream: https://github.com/electron/electron
2024-10-10 22:50:28 +00:00
tags: 'v3*'
2024-10-10 18:13:12 +00:00
steps:
- name: Environment setup
run: apk add grep git sed coreutils bash nodejs
- name: Fetch destination
uses: actions/checkout@v4
with:
fetch_depth: 1
ref: ci
token: ${{ secrets.CODE_FORGEJO_TOKEN }}
- name: Missing tag detecting
run: |
2024-10-10 23:55:56 +00:00
git ls-remote $upstream "refs/tags/$tags" | grep -v '{' | sed 's|.*/||' | grep -v "nightly" > upstream_tags
2024-10-10 18:13:12 +00:00
git ls-remote ${{ github.server_url}}/${{ github.repository }} "refs/tags/$tags" | grep -v '{' | sed 's|.*/||' > destination_tags
2024-10-11 00:07:06 +00:00
echo "v30.5.2" > destination_tags
2024-10-10 18:13:12 +00:00
cat upstream_tags destination_tags | tr ' ' '\n' | sort | uniq -u > missing_tags
echo "Missing tags:"
cat missing_tags
- name: Missing tag fetch
run: |
git remote add upstream $upstream
while read tag; do
git fetch upstream tag $tag --no-tags
done < missing_tags
- name: Packaging workflow injection
run: |
while read tag; do
git checkout $tag
git tag -d $tag
git checkout ci -- ./.forgejo
git config user.name "forgejo-actions[bot]"
git config user.email "dev@ayakael.net"
git commit -m 'Inject custom workflow'
git tag -a $tag -m $tag
done < missing_tags
- name: Push to destination
2024-10-10 22:59:11 +00:00
run: | # use http 1.1 due to http 2 stream being buggy
git config --global http.version HTTP/1.1
git push --force origin refs/tags/*:refs/tags/* --tags
2024-10-10 18:13:12 +00:00