-
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.
Generate automatic PR summaries for submodule bumps (#62)
Generate automatic PR summaries for submodule bumps
- Loading branch information
Showing
2 changed files
with
41 additions
and
7 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 |
---|---|---|
|
@@ -50,8 +50,19 @@ jobs: | |
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.TENZIR_APP_DEPLOY_KEY }} | ||
- name: Authenticate with google cloud | ||
id: gcloud-login | ||
uses: 'google-github-actions/auth@v2' | ||
with: | ||
credentials_json: ${{ secrets.GCS_SERVICE_ACCOUNT_CREDENTIALS }} | ||
token_format: "access_token" | ||
- name: Update app submodule | ||
if: ${{ inputs.bump-app }} | ||
env: | ||
LOCATION: europe-west3 | ||
MODEL: gemini-1.5-pro | ||
PROJECT_ID: ${{ steps.gcloud-login.outputs.project_id }} | ||
GCLOUD_ACCESS_TOKEN: ${{ steps.gcloud-login.outputs.access_token }} | ||
run: | | ||
git submodule update --init components/app | ||
current_sha=$(git -C components/app rev-parse HEAD) | ||
|
@@ -60,14 +71,9 @@ jobs: | |
upstream_sha_short=$(git -C components/app rev-parse --short origin/main) | ||
if [ ${current_sha} != ${upstream_sha} ]; then | ||
# Collect all files in the `changelog` directory that | ||
# were added since the last bump. | ||
names=$(git -C components/app diff --name-status HEAD origin/main -- changelog/ | grep -E '^(A|M)' | awk '{print $2}') | ||
git -C components/app checkout origin/main | ||
echo -e "Bump app component from ${current_sha_short} to ${upstream_sha_short}\n\nChanges:\n" > commitmsg | ||
for name in ${names}; do | ||
cat components/app/${name} >> commitmsg | ||
done | ||
echo -e "Bump app component from ${current_sha_short} to ${upstream_sha_short}\n\n" > commitmsg | ||
./scripts/describe-component-bump components/app ${current_sha} ${upstream_sha} >> commitmsg ||: | ||
git add components/app | ||
git commit -F commitmsg | ||
git push -u origin main:main | ||
|
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,28 @@ | ||
#!/bin/bash | ||
|
||
SUBMODULE_PATH="$1" | ||
FROM_COMMIT="$2" | ||
TO_COMMIT="$3" | ||
|
||
CHANGELOG_BASE64=$(git -C ${SUBMODULE_PATH} log --stat ${FROM_COMMIT}..${TO_COMMTI} | base64 -w 0) | ||
|
||
REQUEST_JSON=$(cat <<EOF | ||
{ | ||
"contents": { | ||
"role": "user", | ||
"parts": [ | ||
{"text": "Please output a brief summary of the changes that were made in the attached PR. Use roughly one sentence per independent feature or bugfix introduced. Focus on on the user-visible effect and not the technical implementation details."}, | ||
{"inlineData": {"mimeType": "text/plain", "data": "${CHANGELOG_BASE64}"}}, | ||
], | ||
} | ||
} | ||
EOF | ||
) | ||
|
||
RESPONSE=$(curl -s -X POST \ | ||
-H "Authorization: Bearer ${GCLOUD_ACCESS_TOKEN}" \ | ||
-H "Content-Type: application/json" \ | ||
https://${LOCATION}-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/${LOCATION}/publishers/google/models/${MODEL}:generateContent \ | ||
-d "${REQUEST_JSON}") | ||
|
||
echo ${RESPONSE} | jq -r .candidates[0].content.parts[0].text |