Skip to content

chore(deps-py)(deps): update fastapi requirement from >=0.109.0 to >=0.138.0 in /api #80

chore(deps-py)(deps): update fastapi requirement from >=0.109.0 to >=0.138.0 in /api

chore(deps-py)(deps): update fastapi requirement from >=0.109.0 to >=0.138.0 in /api #80

name: Notify Google Chat on Dependabot Events
on:
pull_request_target:
types: [opened]
pull_request:
types: [closed]
push:
branches: [main]
permissions:
contents: read
pull-requests: read
jobs:
notify:
name: Post Dependabot event to Google Chat
runs-on: ubuntu-latest
# Trigger conditions:
# - opened/closed events: only when the PR was authored by dependabot[bot]
# - push events: only when the head commit looks like a Dependabot squash
# (commit message starts with chore(deps- which is our configured prefix)
if: |
(github.event_name != 'push' && github.event.pull_request.user.login == 'dependabot[bot]') ||
(github.event_name == 'push' && startsWith(github.event.head_commit.message, 'chore(deps-'))
steps:
- name: Resolve PR for push event
id: pr_lookup
if: github.event_name == 'push'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_SHA: ${{ github.event.head_commit.id }}
run: |
# Find the PR that produced this squash commit on main.
PR_JSON=$(gh api "repos/${{ github.repository }}/commits/${COMMIT_SHA}/pulls" 2>/dev/null | jq '[.[] | select(.user.login == "dependabot[bot]")] | .[0] // empty')
if [[ -z "$PR_JSON" || "$PR_JSON" == "null" ]]; then
echo "No Dependabot PR associated with this commit; skipping."
echo "skip=true" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "skip=false" >> "$GITHUB_OUTPUT"
echo "pr_number=$(echo "$PR_JSON" | jq -r '.number')" >> "$GITHUB_OUTPUT"
echo "pr_url=$(echo "$PR_JSON" | jq -r '.html_url')" >> "$GITHUB_OUTPUT"
echo "pr_title=$(echo "$PR_JSON" | jq -r '.title')" >> "$GITHUB_OUTPUT"
echo "pr_head_ref=$(echo "$PR_JSON" | jq -r '.head.ref')" >> "$GITHUB_OUTPUT"
- name: Stop early if push had no Dependabot PR
if: github.event_name == 'push' && steps.pr_lookup.outputs.skip == 'true'
run: exit 0
- name: Fetch Dependabot metadata (PR events)
id: meta_pr
if: github.event_name != 'push'
uses: dependabot/fetch-metadata@v3
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Fetch Dependabot metadata (push events)
id: meta_push
if: github.event_name == 'push' && steps.pr_lookup.outputs.skip != 'true'
uses: dependabot/fetch-metadata@v3
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
pr-number: ${{ steps.pr_lookup.outputs.pr_number }}
- name: Classify event and update type
id: classify
env:
FM_UPDATE_TYPE: ${{ steps.meta_pr.outputs.update-type || steps.meta_push.outputs.update-type }}
PR_TITLE: ${{ github.event.pull_request.title || steps.pr_lookup.outputs.pr_title }}
ACTION: ${{ github.event.action }}
MERGED: ${{ github.event.pull_request.merged }}
GH_EVENT: ${{ github.event_name }}
run: |
UPDATE_TYPE="${FM_UPDATE_TYPE}"
if [[ -z "$UPDATE_TYPE" || "$UPDATE_TYPE" == "null" ]]; then
if [[ "$PR_TITLE" =~ ([0-9]+)\.([0-9]+)\.([0-9]+).*to.*([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then
OM="${BASH_REMATCH[1]}"; Om="${BASH_REMATCH[2]}"
NM="${BASH_REMATCH[4]}"; Nm="${BASH_REMATCH[5]}"
if [[ "$OM" != "$NM" ]]; then UPDATE_TYPE="version-update:semver-major"
elif [[ "$Om" != "$Nm" ]]; then UPDATE_TYPE="version-update:semver-minor"
else UPDATE_TYPE="version-update:semver-patch"; fi
else
UPDATE_TYPE="unknown"
fi
fi
EVENT="skip"
if [[ "$GH_EVENT" == "pull_request_target" && "$ACTION" == "opened" ]]; then
if [[ "$UPDATE_TYPE" == "version-update:semver-major" ]]; then EVENT="opened_major"
else EVENT="opened_minor_patch"; fi
elif [[ "$GH_EVENT" == "pull_request" && "$ACTION" == "closed" && "$MERGED" == "true" ]]; then
EVENT="merged"
elif [[ "$GH_EVENT" == "push" ]]; then
EVENT="merged"
fi
case "$UPDATE_TYPE" in
version-update:semver-patch) UPDATE_LABEL="patch update";;
version-update:semver-minor) UPDATE_LABEL="minor update";;
version-update:semver-major) UPDATE_LABEL="major update (may contain breaking changes)";;
*) UPDATE_LABEL="update";;
esac
echo "event=$EVENT" >> "$GITHUB_OUTPUT"
echo "update-type=$UPDATE_TYPE" >> "$GITHUB_OUTPUT"
echo "update-label=$UPDATE_LABEL" >> "$GITHUB_OUTPUT"
- name: Send Google Chat card (threaded per repo)
if: steps.classify.outputs.event != 'skip'
env:
WEBHOOK_URL: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }}
EVENT: ${{ steps.classify.outputs.event }}
UPDATE_LABEL: ${{ steps.classify.outputs.update-label }}
DEP_NAMES: ${{ steps.meta_pr.outputs.dependency-names || steps.meta_push.outputs.dependency-names }}
ECOSYSTEM: ${{ steps.meta_pr.outputs.package-ecosystem || steps.meta_push.outputs.package-ecosystem }}
DIRECTORY: ${{ steps.meta_pr.outputs.directory || steps.meta_push.outputs.directory }}
PREVIOUS_VERSION: ${{ steps.meta_pr.outputs.previous-version || steps.meta_push.outputs.previous-version }}
NEW_VERSION: ${{ steps.meta_pr.outputs.new-version || steps.meta_push.outputs.new-version }}
DEP_GROUP: ${{ steps.meta_pr.outputs.dependency-group || steps.meta_push.outputs.dependency-group }}
CVSS: ${{ steps.meta_pr.outputs.cvss || steps.meta_push.outputs.cvss || '0' }}
PR_URL: ${{ github.event.pull_request.html_url || steps.pr_lookup.outputs.pr_url }}
PR_NUMBER: ${{ github.event.pull_request.number || steps.pr_lookup.outputs.pr_number }}
PR_TITLE: ${{ github.event.pull_request.title || steps.pr_lookup.outputs.pr_title }}
REPO: ${{ github.repository }}
MERGED_BY: ${{ github.event.pull_request.merged_by.login || github.event.head_commit.author.username || 'app/github-actions' }}
run: |
case "$ECOSYSTEM" in
npm_and_yarn) ECO_LABEL="npm";;
pip) ECO_LABEL="pip";;
github_actions) ECO_LABEL="GitHub Actions";;
docker) ECO_LABEL="Docker";;
*) ECO_LABEL="$ECOSYSTEM";;
esac
ECO_DISPLAY="$ECO_LABEL"
if [[ -n "$DIRECTORY" && "$DIRECTORY" != "/" ]]; then
ECO_DISPLAY="$ECO_LABEL ($DIRECTORY)"
fi
if [[ -n "$PREVIOUS_VERSION" && -n "$NEW_VERSION" ]]; then
VERSION_TEXT="$PREVIOUS_VERSION -> $NEW_VERSION"
else
VERSION_TEXT="see PR for versions"
fi
if [[ -n "$DEP_GROUP" ]]; then
PKG_COUNT=$(echo "$DEP_NAMES" | tr ',' '\n' | wc -l | tr -d ' ')
PKG_SUMMARY="$DEP_GROUP group ($PKG_COUNT packages)"
else
PKG_SUMMARY="$DEP_NAMES"
fi
case "$EVENT" in
opened_minor_patch)
HEADER_TITLE="Safe update - auto-merging after CI"
STATUS_LABEL="Action Required"
STATUS_TEXT="No action needed. Auto-merge enabled; will merge once CI passes."
BUTTON_TEXT="View PR"
;;
opened_major)
HEADER_TITLE="MAJOR version bump - human review required"
STATUS_LABEL="Action Required"
STATUS_TEXT="This is a MAJOR version upgrade and may contain breaking changes. Please review and merge manually if safe."
BUTTON_TEXT="Review PR"
;;
merged)
HEADER_TITLE="Merged into main"
STATUS_LABEL="Merged By"
if [[ -n "$MERGED_BY" && "$MERGED_BY" != "null" ]]; then
STATUS_TEXT="$MERGED_BY"
else
STATUS_TEXT="dependabot[bot] (auto-merge)"
fi
BUTTON_TEXT="View PR"
;;
esac
SUBTITLE="$REPO - PR #$PR_NUMBER"
CARD_ID="dependabot-$EVENT-$(date +%s)"
THREAD_KEY=$(echo "$REPO" | tr '[:upper:]' '[:lower:]' | tr '/' '-')
THREADED_URL="${WEBHOOK_URL}&threadKey=${THREAD_KEY}&messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD"
jq -n \
--arg cardId "$CARD_ID" \
--arg title "$HEADER_TITLE" \
--arg subtitle "$SUBTITLE" \
--arg statusLabel "$STATUS_LABEL" \
--arg statusText "$STATUS_TEXT" \
--arg prTitle "$PR_TITLE" \
--arg pkgSummary "$PKG_SUMMARY" \
--arg versionText "$VERSION_TEXT" \
--arg updateLabel "$UPDATE_LABEL" \
--arg ecoDisplay "$ECO_DISPLAY" \
--arg buttonText "$BUTTON_TEXT" \
--arg prUrl "$PR_URL" \
--arg cvss "$CVSS" \
'{
cardsV2: [{
cardId: $cardId,
card: {
header: {
title: $title,
subtitle: $subtitle,
imageUrl: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
imageType: "CIRCLE"
},
sections: [{
widgets: (
[
{decoratedText: {topLabel: $statusLabel, text: $statusText, wrapText: true}},
{decoratedText: {topLabel: "PR Title", text: $prTitle, wrapText: true}},
{decoratedText: {topLabel: "Package(s)", text: $pkgSummary, wrapText: true}},
{decoratedText: {topLabel: "Version", text: $versionText}},
{decoratedText: {topLabel: "Update Type", text: $updateLabel}},
{decoratedText: {topLabel: "Ecosystem", text: $ecoDisplay}}
]
+ (if ($cvss | IN("0","0.0","")) then [] else [{decoratedText: {topLabel: "CVSS Score (Common Vulnerability Scoring System, 0 to 10 scale)", text: $cvss}}] end)
+ [{buttonList: {buttons: [{text: $buttonText, onClick: {openLink: {url: $prUrl}}}]}}]
)
}]
}
}]
}' > payload.json
curl -sS -X POST "$THREADED_URL" \
-H "Content-Type: application/json; charset=UTF-8" \
-d @payload.json