Skip to content

Commit

Permalink
Merge pull request #10 from HebiRobotics/gogiputtar/testing_github_ac…
Browse files Browse the repository at this point in the history
…tions

Automated config cloning for arms
  • Loading branch information
iamtesch authored Aug 23, 2024
2 parents a756074 + 6b7cb74 commit ef702b5
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/update-arm-config-directory.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
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

0 comments on commit ef702b5

Please sign in to comment.