Open Go Update PR #33
This file contains 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: 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: '' | |
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@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Setup Python and pip | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Install dependencies | |
run: | | |
python3 -m pip install -r requirements.txt | |
- name: Update Go version | |
run: | | |
inv update-go -v "${{ inputs.go_version }}" --check-archive | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
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@v7 | |
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') | |
}); |