Skip to content

Bump Datadog CI

Bump Datadog CI #63

# This workflow automatically creates a PR bumping datadog-ci in the CI integration.
name: Bump Datadog CI
env:
GIT_AUTHOR_EMAIL: 'packages@datadoghq.com'
GIT_AUTHOR_NAME: 'ci.datadog-ci'
on:
workflow_dispatch:
inputs:
datadog_ci_version:
description: 'Version of datadog-ci to install (`latest` or `major.minor.patch`)'
type: string
default: 'latest'
jobs:
bump-datadog-ci:
runs-on: ubuntu-latest
steps:
# Do the changes
- name: Get GitHub App token
id: get-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.RELEASE_AUTOMATION_GITHUB_APP_ID }}
private-key: ${{ secrets.RELEASE_AUTOMATION_GITHUB_APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.get-token.outputs.token }}
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'yarn'
- name: Create release branch
run: git checkout -b local-branch
- name: Set git user
run: |
git config user.name "${GIT_AUTHOR_NAME}"
git config user.email "${GIT_AUTHOR_EMAIL}"
- name: Install dependencies
run: yarn install
- name: Bump datadog-ci
id: bump-datadog-ci
run: |
VERSION=${{ github.event.inputs.datadog_ci_version }}
if [ "$VERSION" = "latest" ]; then
VERSION=$(npm view @datadog/datadog-ci --json | jq -r '.version')
fi
yarn add @datadog/datadog-ci@^$VERSION
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Create bump commit
run: git commit -a --message '[dep] Bump datadog-ci to `${{ steps.bump-datadog-ci.outputs.VERSION }}`'
- name: Push the branch
run: git push -u origin local-branch:bump-datadog-ci/${{ steps.bump-datadog-ci.outputs.VERSION }}
# Create the pull request
- name: Create pull request
id: create-pull-request
uses: actions/github-script@v7
with:
github-token: ${{ steps.get-token.outputs.token }}
script: |
const { data: pullRequest } = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
base: 'main',
head: 'bump-datadog-ci/${{ steps.bump-datadog-ci.outputs.VERSION }}',
title: '[dep] Bump datadog-ci to `${{ steps.bump-datadog-ci.outputs.VERSION }}`',
body: 'This PR bumps [datadog-ci](https://github.com/DataDog/datadog-ci) to version [`${{ steps.bump-datadog-ci.outputs.VERSION }}`](https://github.com/DataDog/datadog-ci/releases/tag/v${{ steps.bump-datadog-ci.outputs.VERSION }})'
})
core.setOutput('PULL_REQUEST_NUMBER', pullRequest.number)
- name: Create comment
uses: actions/github-script@v7
with:
github-token: ${{ steps.get-token.outputs.token }}
script: |
const body = `This PR was automatically created because a new version of datadog-ci was published.
> [!IMPORTANT]
> **You are not done!**
>
> Once this PR is merged, please run the ["Create Release PR" workflow](../actions/workflows/release-version.yml).
> This time, it will create a **release PR** for you, which will publish the CI integration once merged.`
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ steps.create-pull-request.outputs.PULL_REQUEST_NUMBER }},
body,
})