Skip to content

Update Datadog upstream dependency #262

Update Datadog upstream dependency

Update Datadog upstream dependency #262

name: Update Datadog upstream dependency
on:
schedule:
- cron: '15 9 * * *'
workflow_dispatch:
inputs:
upstream_branch:
description: 'Branch in StackVista/datadog-agent-upstream-for-process-agent to track'
required: false
default: 'stackstate-7.62.2'
permissions:
contents: read
concurrency:
group: update-datadog-dependency
cancel-in-progress: false
jobs:
update-dependency:
runs-on: ubuntu-latest
steps:
- name: Create updatecli GitHub App token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3
with:
client-id: ${{ vars.UPDATECLI_GH_APP_CLIENT_ID }}
private-key: ${{ secrets.UPDATECLI_GH_APP_PRIVATE_KEY }}
permission-contents: write
permission-pull-requests: write
repositories: stackstate-process-agent
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: go.mod
cache: true
- name: Ensure jq is available
run: |
set -euo pipefail
if ! command -v jq >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y jq
fi
- name: Run updater script
id: update
shell: bash
env:
UPSTREAM_BRANCH: ${{ github.event.inputs.upstream_branch }}
run: |
set -euo pipefail
# Use provided input if present; otherwise default to the configured default value
BRANCH="${UPSTREAM_BRANCH}"
if [ -z "$BRANCH" ]; then BRANCH='stackstate-7.62.2'; fi
COMMIT=$(git ls-remote https://github.com/StackVista/datadog-agent-upstream-for-process-agent.git "${BRANCH}" | tail -n 1 | awk '{print $1}')
echo "Upstream branch: $BRANCH, commit: $COMMIT"
if [ -z "$COMMIT" ]; then
echo "Could not resolve commit for branch '$BRANCH'" >&2
exit 1
fi
SHORT_COMMIT=$(echo "$COMMIT" | cut -c1-12)
COMMIT_URL="https://github.com/StackVista/datadog-agent-upstream-for-process-agent/commit/${COMMIT}"
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
echo "commit=$COMMIT" >> "$GITHUB_OUTPUT"
echo "short_commit=$SHORT_COMMIT" >> "$GITHUB_OUTPUT"
echo "commit_url=$COMMIT_URL" >> "$GITHUB_OUTPUT"
chmod +x ./update-datadog-dependency.sh
./update-datadog-dependency.sh -b "$BRANCH"
# Detect whether anything changed (e.g., go.mod / go.sum / others)
if git diff --quiet; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Create pull request if changes detected
if: steps.update.outputs.changed == 'true'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
GH_REPO: ${{ github.repository }}
BASE_BRANCH: ${{ github.ref_name }}
HEAD_BRANCH: update-datadog-${{ steps.update.outputs.short_commit }}
COMMIT_MESSAGE: >-
chore: update datadog-agent upstream to
${{ steps.update.outputs.commit }}
(branch ${{ steps.update.outputs.branch }})
PR_TITLE: >-
chore: update datadog-agent upstream
(${{ steps.update.outputs.branch }}) ->
${{ steps.update.outputs.short_commit }}
PR_BODY: |
This automated PR updates all github.com/DataDog/datadog-agent module replaces to the upstream mirror at the latest commit.
• Branch: `${{ steps.update.outputs.branch }}`
• Commit: `${{ steps.update.outputs.commit }}`
• Link: ${{ steps.update.outputs.commit_url }}
Command executed:
`./update-datadog-dependency.sh -b "${{ steps.update.outputs.branch }}"`
Re-run this workflow with a different `upstream_branch` to refresh the PR.
run: |
chmod +x .github/scripts/open-signed-pr.sh
.github/scripts/open-signed-pr.sh
- name: No updates needed
if: steps.update.outputs.changed != 'true'
run: echo "No dependency updates detected; skipping PR creation."