-
Notifications
You must be signed in to change notification settings - Fork 4
54 lines (50 loc) · 2.11 KB
/
sync-mailing-list-mirror.yml
File metadata and controls
54 lines (50 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: sync-mailing-list-mirror
on:
workflow_dispatch:
schedule:
- cron: "*/5 * * * *"
env:
MIRROR_REF: ${{ fromJSON(vars.CONFIG).mailrepo.mirrorRef }}
SOURCE_REPOSITORY: ${{ fromJSON(vars.CONFIG).mailrepo.url }}${{ fromJSON(vars.CONFIG).mailrepo.public_inbox_epoch }}
TARGET_GITHUB_REPOSITORY: ${{ fromJSON(vars.CONFIG).mailrepo.owner }}/${{ fromJSON(vars.CONFIG).mailrepo.name }}
concurrency:
group: sync-mailing-list-mirror
cancel-in-progress: true
jobs:
sync-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" "$MIRROR_REF")" &&
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 "${MIRROR_REF#refs/heads/}" --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:"$MIRROR_REF"
- 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:$GITHUB_TOKEN@github.com/$TARGET_GITHUB_REPOSITORY "$MIRROR_REF"