Skip to content

Merge pull request #17 from HebiRobotics/iamtesch/add-matlab-as-getti… #40

Merge pull request #17 from HebiRobotics/iamtesch/add-matlab-as-getti…

Merge pull request #17 from HebiRobotics/iamtesch/add-matlab-as-getti… #40

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, hebi-matlab-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/arms/config
cp -r arms/config ${{ matrix.repo }}/kits/arms/config
# --- Commit and Push Changes and create PR ---
- name: Commit and Push changes to ${{ matrix.repo }} and open PR
env:
GITHUB_TOKEN: ${{ secrets.OTHER_REPO_PAT }}
run: |
cd ${{ matrix.repo }}
git checkout -b update-config
CHANGES=$(git diff)
if [ -z "$CHANGES" ]
then
echo "No changes to commit! Exiting!"
exit 0
fi
git add kits/arms/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
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 main