-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (79 loc) · 2.8 KB
/
Copy pathsync.yml
File metadata and controls
93 lines (79 loc) · 2.8 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Sync release
on:
workflow_dispatch:
repository_dispatch:
types: [sync-release]
permissions:
id-token: write
contents: write
actions: write
attestations: write
env:
GH_TOKEN: ${{ github.token }}
SOURCE_REPO: "Liliya2727/AZenith"
MODULE_NAME: "AZenith"
jobs:
get_latest_tag:
runs-on: ubuntu-latest
outputs:
latest: ${{ steps.check.outputs.latest }}
should_sync: ${{ steps.check.outputs.should_sync }}
steps:
- name: Check latest tag
id: check
run: |
LATEST=$(gh api repos/$SOURCE_REPO/tags | jq -r '.[].name' | grep "^AZenith" | sort -V | tail -1)
if [ -z "$LATEST" ]; then
echo "No matching tags found in source repo"
echo "should_sync=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "Latest source tag: $LATEST"
echo "latest=$LATEST" >> $GITHUB_OUTPUT
if gh api repos/$GITHUB_REPOSITORY/releases/tags/$LATEST >/dev/null 2>&1; then
echo "Tag already exists in this repo, skipping"
echo "should_sync=false" >> $GITHUB_OUTPUT
else
echo "Tag is new, will sync"
echo "should_sync=true" >> $GITHUB_OUTPUT
fi
release:
needs: get_latest_tag
if: needs.get_latest_tag.outputs.should_sync == 'true'
runs-on: ubuntu-latest
env:
TAG: ${{ needs.get_latest_tag.outputs.latest }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
token: ${{ secrets.REPO_SYNC_PAT }}
- name: Find and download artifact
id: download
run: |
ASSETS_JSON=$(gh api repos/$SOURCE_REPO/releases/tags/$TAG --jq '.assets')
ASSET_NAME=$(echo "$ASSETS_JSON" | jq -r '.[].name | select(startswith("AZenith") and endswith(".zip"))')
if [ -z "$ASSET_NAME" ]; then
echo "No artifact found matching pattern"
exit 1
fi
echo "Found asset: $ASSET_NAME"
gh release download $TAG --repo $SOURCE_REPO --pattern "$ASSET_NAME"
echo "asset_name=$ASSET_NAME" >> $GITHUB_OUTPUT
- name: Get release body
id: body
run: |
BODY=$(gh release view $TAG --repo $SOURCE_REPO --json body -q .body | sed -E 's/<img[^>]*>//g; s/!\[[^]]*\]\([^)]*\)//g')
echo "body<<EOF" >> $GITHUB_OUTPUT
echo "$BODY" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
uses: KernelSU-Modules-Repo/module_release@main
with:
tag_name: ${{ env.TAG }}
make_latest: true
file: "${{ steps.download.outputs.asset_name }}"
body: ${{ steps.body.outputs.body }}
- uses: actions/attest-build-provenance@v3
with:
subject-path: "${{ steps.download.outputs.asset_name }}"