Skip to content

test again

test again #24

name: Update Config in Other Repos
on:
push:
branches:
- gogiputtar/testing_github_actions
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
env:
GITHUB_TOKEN: ${{ secrets.OTHER_REPO_PAT }}
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 origin --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 }}
env:
GITHUB_TOKEN: ${{ secrets.OTHER_REPO_PAT }}
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