49 lines
1.6 KiB
YAML
49 lines
1.6 KiB
YAML
name: Backport
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
number:
|
|
description: "The pull request # to backport"
|
|
required: true
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
backport:
|
|
permissions:
|
|
contents: write # for Git to git push
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- run: |
|
|
if [[ ! $GITHUB_REF_NAME =~ ^release/v[0-9]+\.[0-9]+\.x$ ]]; then
|
|
echo this workflow should only be run against release branches
|
|
exit 1
|
|
fi
|
|
|
|
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
|
|
with:
|
|
# history is needed to run git cherry-pick below
|
|
fetch-depth: 0
|
|
|
|
- name: Use CLA approved github bot
|
|
run: .github/scripts/use-cla-approved-github-bot.sh
|
|
|
|
- name: Create pull request
|
|
env:
|
|
NUMBER: ${{ github.event.inputs.number }}
|
|
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
|
|
GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
|
|
run: |
|
|
commit=$(gh pr view $NUMBER --json mergeCommit --jq .mergeCommit.oid)
|
|
title=$(gh pr view $NUMBER --json title --jq .title)
|
|
|
|
branch="opentelemetrybot/backport-${NUMBER}-to-${GITHUB_REF_NAME//\//-}"
|
|
|
|
git checkout -b $branch
|
|
git cherry-pick $commit
|
|
git push --set-upstream origin $branch
|
|
gh pr create --title "[$GITHUB_REF_NAME] $title" \
|
|
--body "Clean cherry-pick of #$NUMBER to the \`$GITHUB_REF_NAME\` branch." \
|
|
--base $GITHUB_REF_NAME
|