-
Notifications
You must be signed in to change notification settings - Fork 159
60 lines (50 loc) · 1.71 KB
/
mirror-swift.yml
File metadata and controls
60 lines (50 loc) · 1.71 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
# Mirrors the rivetkit-swift folder into a standalone repo so SwiftPM
# can clone quickly without pulling the full monorepo.
name: Mirror rivetkit-swift
on:
push:
branches:
- "**"
tags:
- "**"
jobs:
mirror:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Mirror repo
env:
MIRROR_TOKEN: ${{ secrets.RIVET_GITHUB_PAT }}
run: |
set -euo pipefail
if [ -z "${MIRROR_TOKEN}" ]; then
echo "RIVET_GITHUB_PAT is not set"
exit 1
fi
git config user.name "rivet-bot"
git config user.email "bot@rivet.dev"
git remote remove swift 2>/dev/null || true
git remote add swift "https://x-access-token:${MIRROR_TOKEN}@github.com/rivet-dev/rivetkit-swift.git"
git subtree split --prefix=rivetkit-swift -b swift-mirror
git checkout swift-mirror
if [ ! -f "README.tpl.md" ]; then
echo "README.tpl.md not found in mirror subtree"
exit 1
fi
cp README.tpl.md README.md
git add README.md
if ! git diff --staged --quiet; then
git commit -m "chore: sync README"
fi
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
# SwiftPM expects bare SemVer tags; strip a leading "v" to keep tags consumable.
swift_tag="${GITHUB_REF_NAME#v}"
git tag -f "${swift_tag}" swift-mirror
git push --force swift "refs/tags/${swift_tag}"
else
git push --force swift "swift-mirror:refs/heads/${GITHUB_REF_NAME}"
fi