Skip to content

Open Go Update PR

Open Go Update PR #51

Workflow file for this run

name: Open Go Update PR
on:
workflow_dispatch:
inputs:
go_version:
description: 'Go version'
required: true
type: string
open_pr:
description: 'Whether to open a PR'
required: false
type: boolean
default: true
draft:
description: 'Open a Draft PR'
required: false
type: boolean
default: false
branch:
description: 'Git branch to use (defaults to "gobot/go-update-<go_version>")'
required: false
type: string
default: ''
permissions: {}
env:
BRANCH_NAME: ${{ inputs.branch || format('gobot/go-update-{0}', inputs.go_version) }}
jobs:
open-go-update-pr:
runs-on: ubuntu-latest
permissions:
contents: write # push commit and branch
pull-requests: write # create PR
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.head_ref }}
- name: Setup Python and pip
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: 3.x
- name: Install dependencies
run: |
DDA_VERSION=$(grep DDA_VERSION dda.env | awk -F= '/^DDA_VERSION=/ {print $2}')
python3 -m pip install "git+https://github.com/DataDog/datadog-agent-dev.git@${DDA_VERSION}"
python3 -m dda -v self dep sync -f legacy-build
- name: Update Go version
run: |
inv update-go -v "${{ inputs.go_version }}" --check-archive
- uses: stefanzweifel/git-auto-commit-action@e348103e9026cc0eee72ae06630dbe30c8bf7a79 # v5.1.0
id: autocommit
with:
# [push_to_datadog_agent] prefix trigger 'push_to_datadog_agent' gitlab job
commit_message: "[push_to_datadog_agent] Update go version to ${{ inputs.go_version }}"
branch: ${{ env.BRANCH_NAME }}
create_branch: true
- name: Create Pull Request
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: ${{ inputs.open_pr && steps.autocommit.outputs.changes_detected }}
with:
# TODO: if minor update, add changelog to the PR body: https://tip.golang.org/doc/go1.21
script: |
github.rest.pulls.create({
title: `Update Go version to ${{ inputs.go_version }}`,
owner: context.repo.owner,
repo: context.repo.repo,
head: "${{ env.BRANCH_NAME }}",
base: context.ref,
draft: ${{ inputs.draft }},
body: [
'## Update docker images to Go ${{ inputs.go_version }}',
'For more information about this version, see the [Go release notes](https://golang.org/doc/devel/release.html#go${{ inputs.go_version }}) and the [Github milestone](https://github.com/golang/go/issues?q=milestone%3AGo${{ inputs.go_version }}+label%3ACherryPickApproved).',
].join('\n')
});