forked from DataDog/datadog-process-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (84 loc) · 3.7 KB
/
update-datadog-dependency.yml
File metadata and controls
98 lines (84 loc) · 3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: Update Datadog upstream dependency
on:
schedule:
# Every day at 09:15 UTC
- 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: write
pull-requests: write
jobs:
update-dependency:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
# Use the Go version from go.mod
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
run: |
set -euo pipefail
# Use provided input if present; otherwise default to the configured default value
BRANCH='${{ github.event.inputs.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'
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
with:
title: |
chore: update datadog-agent upstream (${{ steps.update.outputs.branch }}) -> ${{ steps.update.outputs.short_commit }}
commit-message: |
chore: update datadog-agent upstream to ${{ steps.update.outputs.commit }} (branch ${{ steps.update.outputs.branch }})
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.
branch: update-datadog-${{ steps.update.outputs.short_commit }}
delete-branch: true
- name: No updates needed
if: steps.update.outputs.changed != 'true'
run: echo "No dependency updates detected; skipping PR creation."