Check for New Datadog Agent Releases #230
This file contains hidden or 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
| name: Check for New Datadog Agent Releases | |
| on: | |
| schedule: | |
| # Run daily at 10:00 UTC | |
| - cron: "0 10 * * *" | |
| workflow_dispatch: | |
| env: | |
| NODE_VERSION: "22" | |
| jobs: | |
| check-upstream: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.REPO_TOKEN }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm ci --omit optional | |
| - name: Check for new upstream release | |
| id: check | |
| run: | | |
| # Get latest Datadog Agent release with error handling | |
| echo "Fetching latest Datadog Agent release..." | |
| RESPONSE=$(curl -s https://api.github.com/repos/DataDog/datadog-agent/releases/latest) | |
| # Check if curl succeeded | |
| if [ $? -ne 0 ]; then | |
| echo "Error: Failed to fetch release data from GitHub API" | |
| exit 1 | |
| fi | |
| # Debug: show the response | |
| echo "API Response: $RESPONSE" | |
| # Extract tag name | |
| LATEST_RELEASE=$(echo "$RESPONSE" | jq -r '.tag_name') | |
| # Check if jq extraction succeeded | |
| if [ "$LATEST_RELEASE" = "null" ] || [ -z "$LATEST_RELEASE" ]; then | |
| echo "Error: Failed to extract tag_name from API response" | |
| echo "Response was: $RESPONSE" | |
| exit 1 | |
| fi | |
| echo "Latest upstream release: $LATEST_RELEASE" | |
| # Check if we already have this version tagged (with v prefix) | |
| if git tag --list | grep -q "^v${LATEST_RELEASE}$"; then | |
| echo "Version v$LATEST_RELEASE already exists" | |
| else | |
| echo "New version found: $LATEST_RELEASE" | |
| echo "Creating tag: v$LATEST_RELEASE" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| npm version "v$LATEST_RELEASE" | |
| git push origin "v$LATEST_RELEASE" | |
| fi |