-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (63 loc) · 2.52 KB
/
update-arm-config-directory.yml
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
name: Update Config in Other Repos
on:
push:
branches:
- main
jobs:
check-token:
runs-on: ubuntu-latest
steps:
- name: Check if token is valid
run: |
RESPONSE=$(curl -H "Authorization: token ${{ secrets.OTHER_REPO_PAT }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/user)
if echo "$RESPONSE" | grep -q "Bad credentials"; then
echo "Invalid Token"
exit 1
else
echo "Token is valid"
fi
update-config:
runs-on: ubuntu-latest
needs: check-token
strategy:
fail-fast: false
matrix:
repo: [hebi-python-examples, hebi-cpp-examples]
steps:
- name: Checkout robot-config repo
uses: actions/checkout@v4
- name: Set up Git
run: |
git config --global user.name 'Github Actions robot-config auto-bot'
git config --global user.email '[email protected]'
# --- Clone Target Repo ---
- name: Clone ${{ matrix.repo }} repo
run: |
git clone https://github.com/HebiRobotics/${{ matrix.repo }}.git
cd ${{ matrix.repo }}
# Delete existing update-config branch if it exists
git fetch origin
git branch -D update-config || true
git push https://${{ secrets.OTHER_REPO_PAT }}@github.com/HebiRobotics/${{ matrix.repo }}.git --delete update-config || true
# --- Replace Config Directory ---
- name: Replace arm's config directory in ${{ matrix.repo }}
run: |
rm -rf ${{ matrix.repo }}/kits/arm/config
cp -r arms/config ${{ matrix.repo }}/kits/arm/config
# --- Commit and Push Changes ---
- name: Commit and Push changes to ${{ matrix.repo }}
run: |
cd ${{ matrix.repo }}
git checkout -b update-config
git add kits/arm/config
git commit -m "Update config directory from robot-config"
git push https://${{ secrets.OTHER_REPO_PAT }}@github.com/HebiRobotics/${{ matrix.repo }}.git update-config
# --- Create Pull Request ---
- name: Create Pull Request for ${{ matrix.repo }}
env:
GITHUB_TOKEN: ${{ secrets.OTHER_REPO_PAT }}
run: |
cd ${{ matrix.repo }}
gh pr create --title "Update config directory from robot-config" --body "This automated PR updates the config directory from the latest version in the robot-config repository." --head update-config --base master