-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-submodules.sh
More file actions
executable file
·69 lines (55 loc) · 1.84 KB
/
setup-submodules.sh
File metadata and controls
executable file
·69 lines (55 loc) · 1.84 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
#!/bin/bash
# Script to create GitHub repos and convert actions to submodules
# Run this from the flxbl-actions directory
set -e
ORG="flxbl-io"
ACTIONS="get-github-token auth-devhub lock-environment unlock-environment auth-environment fetch-environments match-pool add-comment find-comment analyze-issue"
echo "This script will:"
echo "1. Create public GitHub repos for each action"
echo "2. Push each action to its repo"
echo "3. Remove local directories and add as submodules"
echo ""
read -p "Continue? (y/n) " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
for action in $ACTIONS; do
echo ""
echo "=== Processing $action ==="
# Create GitHub repo
echo "Creating repo $ORG/$action..."
gh repo create "$ORG/$action" --public --description "GitHub Action: $action" || echo "Repo may already exist"
# Push to GitHub
echo "Pushing to GitHub..."
cd "$action"
git remote remove origin 2>/dev/null || true
git remote add origin "git@github.com:$ORG/$action.git"
git branch -M main
git push -u origin main --force
cd ..
# Store path for submodule
echo "$action" >> .submodules-to-add
done
echo ""
echo "=== Converting to submodules ==="
for action in $ACTIONS; do
echo "Converting $action to submodule..."
# Remove local directory
rm -rf "$action"
# Add as submodule
git submodule add "git@github.com:$ORG/$action.git" "$action"
done
# Commit submodule changes
git add .gitmodules
git commit -m "chore: convert actions to submodules"
rm -f .submodules-to-add
echo ""
echo "=== Done! ==="
echo "All actions are now submodules pointing to their GitHub repos."
echo ""
echo "To clone this repo with submodules:"
echo " git clone --recurse-submodules git@github.com:$ORG/flxbl-actions.git"
echo ""
echo "To update all submodules:"
echo " git submodule update --remote --merge"