Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .github/dependabot.yml
Empty file.
124 changes: 124 additions & 0 deletions .github/workflows/dependabot-notify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Notify Dependabot PR

on:
pull_request_target:
types: [opened, reopened, synchronize]

workflow_dispatch:
inputs:
mode:
description: "Modo de ejecución"
required: true
default: "test"
type: choice
options:
- test
- prod

jobs:
notify:
runs-on: ubuntu-latest

# Ejecuta si es dependabot o ejecución manual
if: github.actor == 'dependabot[bot]' || github.event_name == 'workflow_dispatch'

steps:
- name: Set mode
id: mode
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "mode=${{ github.event.inputs.mode }}" >> $GITHUB_OUTPUT
else
echo "mode=prod" >> $GITHUB_OUTPUT
fi

- name: Build message context
id: context
run: |
TITLE="${{ github.event.pull_request.title || 'Manual test execution' }}"
URL="${{ github.event.pull_request.html_url || 'https://github.com' }}"
REPO="${{ github.repository }}"
BRANCH="${{ github.head_ref || 'manual-test' }}"

# Detectar tipo de PR
if [[ "$TITLE" == *"security"* ]]; then
TYPE="🔴 SECURITY UPDATE"
elif [[ "$TITLE" == *"bump"* ]]; then
TYPE="📦 Dependency Update"
else
TYPE="🟡 General Update"
fi

echo "title=$TITLE" >> $GITHUB_OUTPUT
echo "url=$URL" >> $GITHUB_OUTPUT
echo "repo=$REPO" >> $GITHUB_OUTPUT
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
echo "type=$TYPE" >> $GITHUB_OUTPUT

# =========================
# 🧪 MODO TEST
# =========================
- name: Send Slack (TEST)
if: steps.mode.outputs.mode == 'test'
run: |
curl -X POST -H 'Content-type: application/json' \
--data "{
\"text\": \"🧪 TEST Dependabot notification\",
\"blocks\": [
{
\"type\": \"section\",
\"text\": {
\"type\": \"mrkdwn\",
\"text\": \"🧪 *[TEST MODE]* Dependabot Notification\"
}
},
{
\"type\": \"section\",
\"fields\": [
{ \"type\": \"mrkdwn\", \"text\": \"*Repo:*\n${{ steps.context.outputs.repo }}\" },
{ \"type\": \"mrkdwn\", \"text\": \"*Branch:*\n${{ steps.context.outputs.branch }}\" },
{ \"type\": \"mrkdwn\", \"text\": \"*Título:*\n${{ steps.context.outputs.title }}\" }
]
}
]
}" \
${{ secrets.SLACK_WEBHOOK_DTEST }}

# =========================
# 🚀 MODO PRODUCCIÓN
# =========================
- name: Send Slack (PROD)
if: steps.mode.outputs.mode == 'prod'
run: |
curl -X POST -H 'Content-type: application/json' \
--data "{
\"text\": \"Dependabot PR: ${{ steps.context.outputs.title }}\",
\"blocks\": [
{
\"type\": \"section\",
\"text\": {
\"type\": \"mrkdwn\",
\"text\": \"${{ steps.context.outputs.type }}\n🤖 *Dependabot PR creado*\"
}
},
{
\"type\": \"section\",
\"fields\": [
{ \"type\": \"mrkdwn\", \"text\": \"*Repo:*\n${{ steps.context.outputs.repo }}\" },
{ \"type\": \"mrkdwn\", \"text\": \"*Branch:*\n${{ steps.context.outputs.branch }}\" },
{ \"type\": \"mrkdwn\", \"text\": \"*Título:*\n${{ steps.context.outputs.title }}\" }
]
},
{
\"type\": \"actions\",
\"elements\": [
{
\"type\": \"button\",
\"text\": { \"type\": \"plain_text\", \"text\": \"Ver PR\" },
\"url\": \"${{ steps.context.outputs.url }}\"
}
]
}
]
}" \
${{ secrets.SLACK_WEBHOOK_DEP }}
103 changes: 103 additions & 0 deletions .github/workflows/dependabot-reminder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Dependabot Reminder

on:
schedule:
- cron: "0 12 * * *" # diario
workflow_dispatch:

jobs:
reminder:
runs-on: ubuntu-latest

steps:
- name: Buscar PRs abiertos
run: |
PRS=$(gh pr list \
--repo ${{ github.repository }} \
--state open \
--json title,url,createdAt,author)

CRITICAL=""
PENDING=""
CRITICAL_COUNT=0
PENDING_COUNT=0

echo "$PRS" | jq -c '.[]' | while read pr; do
AUTHOR=$(echo $pr | jq -r '.author.login')
TITLE=$(echo $pr | jq -r '.title')
URL=$(echo $pr | jq -r '.url')
CREATED=$(echo $pr | jq -r '.createdAt')

if [[ "$AUTHOR" != "dependabot[bot]" ]]; then
continue
fi

CREATED_TS=$(date -d "$CREATED" +%s)
NOW_TS=$(date +%s)
AGE=$(( (NOW_TS - CREATED_TS) / 86400 ))

if [[ "$TITLE" == *"security"* && $AGE -ge 1 ]]; then
CRITICAL="${CRITICAL}\n• <${URL}|${TITLE}> (${AGE}d)"
CRITICAL_COUNT=$((CRITICAL_COUNT+1))
elif [[ $AGE -ge 3 ]]; then
PENDING="${PENDING}\n• <${URL}|${TITLE}> (${AGE}d)"
PENDING_COUNT=$((PENDING_COUNT+1))
fi
done

if [[ $CRITICAL_COUNT -eq 0 && $PENDING_COUNT -eq 0 ]]; then
echo "✅ No hay PRs pendientes relevantes"
exit 0
fi

REPO="${{ github.repository }}"

PAYLOAD=$(jq -n \
--arg repo "$REPO" \
--arg critical "$CRITICAL" \
--arg pending "$PENDING" \
--argjson ccount $CRITICAL_COUNT \
--argjson pcount $PENDING_COUNT \
'{
text: "Dependabot Summary",
blocks: [
{
type: "section",
text: {
type: "mrkdwn",
text: "🤖 *Dependabot Summary*\n*Repo:* \($repo)"
}
},
(
if $ccount > 0 then
{
type: "section",
text: {
type: "mrkdwn",
text: "🔴 *Critical Security Updates (\($ccount))*\($critical)"
}
}
else empty end
),
(
if $pcount > 0 then
{
type: "section",
text: {
type: "mrkdwn",
text: "🟡 *Pending Updates (\($pcount))*\($pending)"
}
}
else empty end
)
]
}')

echo "$PAYLOAD"

curl -X POST -H 'Content-type: application/json' \
--data "$PAYLOAD" \
${{ secrets.SLACK_WEBHOOK_DEP }}

env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.9
// swift-tools-version:5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down
12 changes: 11 additions & 1 deletion Sources/Segment/Plugins/Platforms/iOS/iOSLifecycleEvents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class iOSLifecycleEvents: PlatformPlugin, iOSLifecycle {
}

let sourceApp: String = launchOptions?[UIApplication.LaunchOptionsKey.sourceApplication] as? String ?? ""
let url: String = launchOptions?[UIApplication.LaunchOptionsKey.url] as? String ?? ""
let url = urlFrom(launchOptions)

analytics?.track(name: "Application Opened", properties: [
"from_background": false,
Expand Down Expand Up @@ -101,6 +101,16 @@ class iOSLifecycleEvents: PlatformPlugin, iOSLifecycle {
}
analytics?.track(name: "Application Foregrounded")
}

private func urlFrom(_ launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> String {
if let url = launchOptions?[UIApplication.LaunchOptionsKey.url] as? String {
return url
}
if let url = launchOptions?[UIApplication.LaunchOptionsKey.url] as? NSURL, let rawUrl = url.absoluteString {
return rawUrl
}
return ""
}
}

#endif
2 changes: 1 addition & 1 deletion Sources/Segment/Version.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
// Use release.sh's automation.

// BREAKING.FEATURE.FIX
internal let __segment_version = "1.7.3"
internal let __segment_version = "1.7.5"