Inject custom workflow
All checks were successful
/ Upload to generic repo (push) Successful in 23s
/ Generate cabal config for edge (push) Successful in 55s

This commit is contained in:
Antoine Martin 2024-09-09 21:53:05 +00:00
parent bee3abab14
commit 5779a0e0dc
2 changed files with 137 additions and 0 deletions

View file

@ -0,0 +1,87 @@
on:
workflow_dispatch:
inputs:
ref_name:
description: 'Tag or commit'
required: true
type: string
push:
tags:
- '*'
jobs:
cabal-config-edge:
name: Generate cabal config for edge
runs-on: x86_64
container:
image: alpine:edge
env:
CI_PROJECT_NAME: git-annex
CI_ALPINE_TARGET_RELEASE: edge
steps:
- name: Environment setup
run: apk add nodejs git cabal patch wget
- name: Repo pull
uses: actions/checkout@v4
with:
fetch-depth: 500
ref: ${{ inputs.ref_name }}
- name: Config generation
run: |
wget 'https://lab.ilot.io/mirrors/git-annex/-/raw/gitlab-ci/ghc-9.8.patch'
patch -p1 -i ghc-9.8.patch
HOME="${{ github.workspace}}"/cabal_cache cabal update
HOME="${{ github.workspace}}"/cabal_cache cabal v2-freeze --shadow-installed-packages --strong-flags --flags="+assistant +webapp +pairing +production +torrentparser +magicmime +benchmark -debuglocks +dbus +networkbsd +gitlfs +httpclientrestricted"
find .
mv cabal.project.freeze git-annex-${{ input.ref_name }}-$CI_ALPINE_TARGET_RELEASE.config
- name: Package upload
uses: forgejo/upload-artifact@v3
with:
name: cabalconfigedge
path: git-annex*
cabal-config-v320:
name: Generate cabal config for edge
runs-on: x86_64
container:
image: alpine:3.20
env:
CI_PROJECT_NAME: git-annex
CI_ALPINE_TARGET_RELEASE: v3.20
steps:
- name: Environment setup
run: apk add nodejs git cabal patch wget
- name: Repo pull
uses: actions/checkout@v4
with:
fetch-depth: 500
ref: ${{ inputs.ref_name }}
- name: Config generation
run: |
wget 'https://lab.ilot.io/mirrors/git-annex/-/raw/gitlab-ci/ghc-9.8.patch'
patch -p1 -i ghc-9.8.patch
HOME="${{ github.workspace }}"/cabal_cache cabal update
HOME="${{ github.workspace }}"/cabal_cache cabal v2-freeze --shadow-installed-packages --strong-flags --flags="+assistant +webapp +pairing +production +torrentparser +magicmime +benchmark -debuglocks +dbus +networkbsd +gitlfs +httpclientrestricted"
mv cabal.project.freeze git-annex-${{ input.ref_name }}-$CI_ALPINE_TARGET_RELEASE.config
find .
- name: Package upload
uses: forgejo/upload-artifact@v3
with:
name: cabalconfig320
path: git-annex*
upload-tarball:
name: Upload to generic repo
runs-on: x86_64
needs: [cabal-config-edge,cabal-config-v320]
container:
image: alpine:latest
steps:
- name: Environment setup
run: apk add nodejs curl findutils
- name: Package download
uses: forgejo/download-artifact@v3
- name: Package deployment
run: |
find .
curl --user ${{ vars.CODE_FORGEJO_USER }}:${{ secrets.CODE_FORGEJO_TOKEN }} --upload-file ./cabalconfigedge/git-annex.cabal ${{ github.server_url }}/api/packages/mirrors/generic/git-annex/${{ inputs.ref_name }}/git-annex-${{ inputs.ref_name }}-edge.cabal
curl --user ${{ vars.CODE_FORGEJO_USER }}:${{ secrets.CODE_FORGEJO_TOKEN }} --upload-file ./cabalconfig320/git-annex.cabal ${{ github.server_url }}/api/packages/mirrors/generic/git-annex/${{ inputs.ref_name }}/git-annex-${{ inputs.ref_name }}-v320.cabal

View file

@ -0,0 +1,50 @@
on:
workflow_dispatch:
schedule:
- cron: '@hourly'
jobs:
mirror:
name: Pull from upstream
runs-on: x86_64
container:
image: alpine:latest
env:
upstream: https://git.joeyh.name/git/git-annex.git
tags: '10.2024*'
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: |
git ls-remote $upstream "refs/tags/$tags" | grep -v '{' | sed 's|.*/||' > upstream_tags
git ls-remote ${{ github.server_url}}/${{ github.repository }} "refs/tags/$tags" | grep -v '{' | sed 's|.*/||' > destination_tags
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
run: git push --force origin refs/tags/*:refs/tags/* --tags