Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 0 additions & 140 deletions .github/workflows/sync-gitster-git.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
name: sync-git-mailing-list-mirror
name: sync-mailing-list-mirror

on:
workflow_dispatch:
schedule:
- cron: "2,7,12,17,22,27,32,37,42,47,52,57 * * * *"
- cron: "*/5 * * * *"

env:
LORE_EPOCH: 1 # also adjust SOURCE_REPOSITORY
SOURCE_REPOSITORY: https://lore.kernel.org/git/1 # LORE_EPOCH
TARGET_GITHUB_REPOSITORY: gitgitgadget/git-mailing-list-mirror

concurrency:
group: sync-git-mailing-list-mirror
group: sync-mailing-list-mirror
cancel-in-progress: true

jobs:
sync-git-mailing-list-mirror:
sync-mailing-list-mirror:
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
name: sync-git-gui-branches
name: sync-upstream-branches

on:
schedule:
- cron: '31 22 * * *'
workflow_dispatch:

env:
SOURCE_REPOSITORY: j6t/git-gui
TARGET_REPOSITORY: gitgitgadget/git
TARGET_REF_NAMESPACE: git-gui/

# We want to limit queuing to a single workflow run i.e. if there is already
# an active workflow run and a queued one, queue another one canceling the
# already queued one.
concurrency:
group: ${{ github.workflow }}

jobs:
sync-git-gui-branches:
sync-upstream-branches:
runs-on: ubuntu-latest
strategy:
matrix:
spec:
- sourceRepo: j6t/git-gui
targetRepo: gitgitgadget/git
targetRefNamespace: git-gui/
- sourceRepo: gitster/git
targetRepo: gitgitgadget/git
sourceRefRegex: "^refs/heads/(maint-\\d|[a-z][a-z]/)"

steps:
- name: check which refs need to be synchronized
uses: actions/github-script@v7
id: check
with:
script: |
const [targetRepoOwner, targetRepoName] = process.env.TARGET_REPOSITORY.split('/')
const sourceRepo = ${{ toJSON(matrix.spec.sourceRepo) }}
const sourceRefRegexp = ((p) => p ? new RegExp(p) : null)(${{ toJSON(matrix.spec.sourceRefRegex) }})
const targetRepo = ${{ toJSON(matrix.spec.targetRepo) }}
const targetRefNamespace = ${{ toJSON(matrix.spec.targetRefNamespace) }} || ''

const [targetRepoOwner, targetRepoName] = targetRepo.split('/')
core.setOutput('target-repo-owner', targetRepoOwner)
core.setOutput('target-repo-name', targetRepoName)

Expand All @@ -38,27 +48,26 @@ jobs:
for (;;) {
try {
const [owner, repo] = repository.split('/')
let { data } = await github.rest.git.listMatchingRefs({
owner,
repo,
ref: 'heads/'
})

data = data.filter(e => {
if (!e.ref.startsWith('refs/heads/')) return false
e.name = e.ref.slice(11)
return true
})

if (stripRefsPrefix) {
data = data.filter(e => {
if (!e.name.startsWith(stripRefsPrefix)) return false
e.name = e.name.slice(stripRefsPrefix.length)
return (
await github.rest.git.listMatchingRefs({
owner,
repo,
// We cannot match `source-ref-regex` as freely as we
// want with GitHub's REST API, hence we do it below via
// the `filter()` call.
ref: 'heads/'
})
).data
.filter((e) => {
if (sourceRefRegexp && !sourceRefRegexp.test(e.ref)) return false
if (!e.ref.startsWith('refs/heads/')) return false
e.name = e.ref.slice(11)
if (stripRefsPrefix) {
if (!e.name.startsWith(stripRefsPrefix)) return false
e.name = e.name.slice(stripRefsPrefix.length)
}
return true
})
}

return data
.sort((a, b) => a.ref.localeCompare(b.ref))
} catch (e) {
if (e?.status !== 502) throw e
Expand All @@ -72,10 +81,10 @@ jobs:
}
}

const sourceRefs = await getRefs(process.env.SOURCE_REPOSITORY)
const targetRefs = await getRefs(process.env.TARGET_REPOSITORY, process.env.TARGET_REF_NAMESPACE)
const sourceRefs = await getRefs(sourceRepo)
const targetRefs = await getRefs(targetRepo, targetRefNamespace)

const targetPrefix = `refs/heads/${process.env.TARGET_REF_NAMESPACE}`
const targetPrefix = `refs/heads/${targetRefNamespace}`

const refspecs = []
const toFetch = new Set()
Expand Down Expand Up @@ -138,7 +147,7 @@ jobs:
set -ex
git init --bare

git remote add source "${{ github.server_url }}/$SOURCE_REPOSITORY"
git remote add source '${{ github.server_url }}/${{ matrix.spec.sourceRepo }}'
# pretend to be a partial clone
git config remote.source.promisor true
git config remote.source.partialCloneFilter blob:none
Expand All @@ -151,4 +160,4 @@ jobs:
# push the commits
printf '%s' '${{ steps.check.outputs.refspec }}' |
xargs -d ' ' -r git -c http.extraHeader='${{ steps.auth.outputs.header }}' \
push "${{ github.server_url }}/$TARGET_REPOSITORY"
push '${{ github.server_url }}/${{ matrix.spec.targetRepo }}'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ This repository contains GitHub workflows, i.e. automated tasks, that keep [GitG

## Keeping the mirror of the Git mailing list up to date

The `sync-git-mailing-list.yml` workflow keeps the mirror at https://github.com/gitgitgadget/git-mailing-list of the Git mailing list mirror at https://lore.kernel.org/git up to date. Since that mirror chunks the archive by epochs, this mirror fetches each epoch into its own branch: the oldest epoch into `lore-0`, the next one into `lore-1`, etc.
The `sync-mailing-list-mirror.yml` workflow keeps the mirror at https://github.com/gitgitgadget/git-mailing-list of the Git mailing list mirror at https://lore.kernel.org/git up to date. Since that mirror chunks the archive by epochs, this mirror fetches each epoch into its own branch: the oldest epoch into `lore-0`, the next one into `lore-1`, etc.

Previously, this workflow lived in the `git-mailing-list` repository in the `sync` branch, which was the default branch because scheduled workflows _must_ live in the default branch.