2020 description : " The new tag or branch to update the platform.branch property to use for targeting the RPC protocol buffers."
2121 required : true
2222 default : " protocol/go/v0.3.0"
23+ pull_request :
24+
2325
2426jobs :
2527 update-platform-branch :
@@ -63,11 +65,13 @@ jobs:
6365 CURRENT_TAG=$(grep -oP '<platform.branch>\K.*(?=</platform.branch>)' pom.xml | head -n1)
6466 if [ "$CURRENT_TAG" = "$LATEST_TAG" ]; then
6567 echo "Platform branch is already up-to-date."
66- exit 1
68+ echo "no_updates=true" >> "$GITHUB_OUTPUT"
69+ exit 0
6770 fi
6871 echo "CURRENT_TAG=$CURRENT_TAG" >> "$GITHUB_ENV"
6972
7073 - name : Check for existing PR
74+ if : steps.check-update.outputs.no_updates != 'true'
7175 id : check-pr
7276 run : |
7377 EXISTING_PR=$(gh pr list --head update-platform-branch --json number --jq '.[0].number')
@@ -78,44 +82,70 @@ jobs:
7882 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
7983
8084 - name : Check out existing PR
81- if : steps.check-pr.outputs.EXISTING_PR != ''
85+ if : steps.check-pr.outputs.EXISTING_PR != '' && steps.check-update.outputs.no_updates != 'true'
8286 run : |
8387 git fetch origin update-platform-branch:update-platform-branch
8488 git checkout update-platform-branch
8589
8690 - name : Update platform.branch in pom.xml files
91+ if : steps.check-update.outputs.no_updates != 'true'
8792 id : update-platform-branch
8893 run : |
8994 find . -name "pom.xml" -exec sed -i.bak "s|<platform.branch>.*</platform.branch>|<platform.branch>${LATEST_TAG}</platform.branch>|g" {} \;
9095 CHANGED_FILES=$(find . -name "pom.xml" -exec diff -u {} {}.bak \;)
9196 if [ -z "$CHANGED_FILES" ]; then
9297 echo "No changes detected in pom.xml files." | tee -a $GITHUB_STEP_SUMMARY
9398 find . -name "pom.xml.bak" -delete
94- echo "no_updates=true" >> $GITHUB_OUTPUT
9599 exit 0
96100 fi
101+ # otherwise output that changes were made
102+ echo "changes=true" >> $GITHUB_OUTPUT
97103 echo "The following pom.xml files were updated: $CHANGED_FILES"
98104 find . -name "pom.xml.bak" -delete
99105
100106 - name : Create new branch
101- if : steps.check-pr.outputs.EXISTING_PR == '' && steps.update-platform-branch.outputs.no_updates ! = 'true'
107+ if : steps.check-pr.outputs.EXISTING_PR == '' && steps.update-platform-branch.outputs.changes = = 'true'
102108 run : |
103- git checkout -b update-platform-branch
104- git add .
105- git commit -m "fix(sdk): Updates to proto version $LATEST_TAG"
106- git push origin update-platform-branch
109+ git checkout -b $BRANCH_NAME
110+ git push origin $BRANCH_NAME
111+ env :
112+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
113+ BRANCH_NAME : update-platform-branch
107114
108- - name : Update existing PR
109- if : steps.check-pr.outputs.EXISTING_PR != '' && steps.update-platform-branch.outputs.no_updates != 'true'
115+ - name : Update files
116+ working-directory : ./web-sdk
117+ if : steps.update-platform-branch.outputs.changes == 'true'
110118 run : |
111- git add .
112- git commit --amend --no-edit
113- git push origin update-platform-branch --force
119+ echo "Committing changes..."
120+ FILES_CHANGED=$(git status --porcelain | awk '{print $2}')
121+ for file in $FILES_CHANGED; do
122+ echo "Committing file: $file"
123+
124+ CONTENT=$(base64 -i $file)
125+ FILENAME=$(basename $file)
126+ MESSAGE="Update $FILENAME to match platform tag $LATEST_TAG"
127+
128+ SHA=$( git rev-parse $BRANCH_NAME:$file 2>/dev/null | grep -E '^[0-9a-f]{40}$' || echo "" )
129+ if [ -z "$SHA" ]; then
130+ SHA=""
131+ fi
132+
133+ gh api --method PUT /repos/opentdf/web-sdk/contents/$file \
134+ --field message="$MESSAGE" \
135+ --field content="$CONTENT" \
136+ --field encoding="base64" \
137+ --field branch="$BRANCH_NAME" \
138+ --field sha="$SHA"
139+ done
140+ env :
141+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
142+ BRANCH_NAME : update-platform-branch
114143
115144 - name : Create New PR
116- if : steps.check-pr.outputs.EXISTING_PR == '' && steps.update-platform-branch.outputs.no_updates ! = 'true'
145+ if : steps.check-pr.outputs.EXISTING_PR == '' && steps.update-platform-branch.outputs.changes = = 'true'
117146 env :
118147 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
148+ BRANCH_NAME : update-platform-branch
119149 run : |
120150 RELEASE_NOTES=$(gh release view protocol/go/$LATEST_TAG --repo opentdf/platform --json body --jq '.body')
121151 cat <<EOF > pr_body.txt
@@ -129,6 +159,6 @@ jobs:
129159 gh pr create \
130160 --title "fix(sdk): Updates to proto version $LATEST_TAG" \
131161 --body-file pr_body.txt \
132- --head update-platform-branch \
162+ --head $BRANCH_NAME \
133163 --base main
134164
0 commit comments