-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from HebiRobotics/gogiputtar/testing_github_ac…
…tions Automated config cloning for arms
- Loading branch information
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||