sync-git-mailing-list-mirror #30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: sync-git-mailing-list-mirror | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "2,7,12,17,22,27,32,37,42,47,52,57 * * * *" | |
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 | |
cancel-in-progress: true | |
jobs: | |
sync-git-mailing-list-mirror: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: check if update is needed | |
id: needs-update | |
run: | | |
set -x | |
echo "org=${TARGET_GITHUB_REPOSITORY%%/*}" >>$GITHUB_OUTPUT && | |
echo "repo=${TARGET_GITHUB_REPOSITORY#*/}" >>$GITHUB_OUTPUT && | |
source="$(git ls-remote "$SOURCE_REPOSITORY" master)" && | |
target="$(git ls-remote https://github.com/"$TARGET_GITHUB_REPOSITORY" lore-$LORE_EPOCH)" && | |
echo "result=$(test "${source%% *}" = "${target%% *}" && echo false || echo true)" >>$GITHUB_OUTPUT | |
- name: Partial clone | |
if: steps.needs-update.outputs.result == 'true' | |
run: | | |
git clone --bare --depth=1 -b lore-$LORE_EPOCH --filter=blob:none https://github.com/$TARGET_GITHUB_REPOSITORY . | |
- name: Update from lore.kernel.org | |
if: steps.needs-update.outputs.result == 'true' | |
run: | | |
git fetch "$SOURCE_REPOSITORY" refs/heads/master:refs/heads/lore-$LORE_EPOCH | |
- name: obtain installation token | |
if: steps.needs-update.outputs.result == 'true' | |
uses: actions/create-github-app-token@v2 | |
id: token | |
with: | |
app-id: ${{ secrets.GITGITGADGET_GITHUB_APP_ID }} | |
private-key: ${{ secrets.GITGITGADGET_GITHUB_APP_PRIVATE_KEY }} | |
owner: ${{ steps.needs-update.outputs.org }} | |
repositories: ${{ steps.needs-update.outputs.repo }} | |
- name: Push to mirror | |
if: steps.needs-update.outputs.result == 'true' | |
env: | |
GITHUB_TOKEN: ${{ steps.token.outputs.token }} | |
run: | | |
git push https://$GITHUB_ACTOR:[email protected]/$TARGET_GITHUB_REPOSITORY lore-$LORE_EPOCH |