-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new CICD trigger to update submodule (#5166)
* add a new trigger to update the git submodule (python-sdk)
- Loading branch information
1 parent
09ecf6a
commit 789489a
Showing
1 changed file
with
71 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,71 @@ | ||
--- | ||
# yamllint disable rule:truthy rule:line-length | ||
name: Handle Submodule Trigger | ||
|
||
on: | ||
repository_dispatch: | ||
types: | ||
- trigger-submodule-update | ||
|
||
jobs: | ||
update-dependencies: | ||
strategy: | ||
matrix: | ||
branch-name: | ||
- main | ||
- develop | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: "${{ matrix.branch-name }}" | ||
submodules: recursive | ||
|
||
- name: Set branch name | ||
id: set-branch-name | ||
run: | | ||
SUBMODULE_PATH="python_sdk" | ||
SDK_VERSION="${{ github.event.client_payload.version }}" | ||
BRANCH_NAME="${{ matrix.branch-name}}-${SUBMODULE_PATH}-${SDK_VERSION}" | ||
echo "SUBMODULE_PATH=$SUBMODULE_PATH" >> $GITHUB_ENV | ||
echo "SDK_VERSION=$SDK_VERSION" >> $GITHUB_ENV | ||
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV | ||
- name: Use the version from the client payload to update the submodule | ||
run: | | ||
echo "Updating submodule to version: ${{ env.SDK_VERSION }}" | ||
echo "Branch name: ${{ env.BRANCH_NAME }}" | ||
# Navigate to the submodule and update it to the specified version | ||
cd ${{ env.SUBMODULE_PATH }} | ||
git fetch --tags | ||
git checkout ${{ env.SDK_VERSION }} | ||
cd - | ||
- name: Prepare the branch for the update | ||
id: prepare-branch | ||
run: | | ||
echo "Checking if branch ${{ env.BRANCH_NAME }} exists..." | ||
BRANCH_EXISTS=$(git ls-remote --heads origin ${{ env.BRANCH_NAME }} | wc -l) | ||
echo "BRANCH_EXISTS=$BRANCH_EXISTS" >> $GITHUB_ENV | ||
- name: Commit and push changes with github-actions-x/commit | ||
uses: github-actions-x/commit@v2.9 | ||
with: | ||
github-token: ${{ secrets.GH_UPDATE_PACKAGE }} | ||
push-branch: ${{ env.BRANCH_NAME }} | ||
commit-message: "chore: update submodule ${{ env.SUBMODULE_PATH }} to version ${{ env.SDK_VERSION }}" | ||
files: ${{ env.SUBMODULE_PATH }}/ | ||
name: opsmill-bot | ||
email: github-bot@opsmill.com | ||
rebase: ${{ env.BRANCH_EXISTS == 1 }} | ||
|
||
- name: Create a pull request | ||
run: | | ||
echo ${{ secrets.GH_UPDATE_PACKAGE_OTTO }} | gh auth login --with-token | ||
gh pr create \ | ||
--title "Update ${{ env.SUBMODULE_PATH }} to version ${{ env.SDK_VERSION }} against ${{ matrix.branch-name}}" \ | ||
--body "This PR updates the submodule ${{ env.SUBMODULE_PATH }} to version ${{ env.SDK_VERSION }}." \ | ||
--base ${{ matrix.branch-name}} \ | ||
--head ${{ env.BRANCH_NAME }} |