Skip to content

Merge branch 'main' into add-missing-permissions #1

Merge branch 'main' into add-missing-permissions

Merge branch 'main' into add-missing-permissions #1

Workflow file for this run

name: Backport
on:
workflow_dispatch:
inputs:
number:
description: "The pull request # to backport"
required: true
permissions:
contents: read
jobs:
backport:
permissions:
contents: write # required for pushing branches
pull-requests: write # required for creating pull requests
runs-on: ubuntu-latest
permissions:

Check failure on line 18 in .github/workflows/backport.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/backport.yml

Invalid workflow file

You have an error in your yaml syntax on line 18
contents: write # required for pushing changes
steps:
- run: |
if [[ ! $GITHUB_REF_NAME =~ ^release/v[0-9]+\.[0-9]+\.x-0\.[0-9]+bx$ ]]; then
echo this workflow should only be run against long-term release branches
exit 1
fi
- uses: actions/checkout@v4
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
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
id: otelbot-token
with:
app-id: ${{ vars.OTELBOT_APP_ID }}
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }}
- 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
GITHUB_TOKEN: ${{ steps.otelbot-token.outputs.token }}
run: |
commit=$(gh pr view $NUMBER --json mergeCommit --jq .mergeCommit.oid)
title=$(gh pr view $NUMBER --json title --jq .title)
branch="otelbot/backport-${NUMBER}-to-${GITHUB_REF_NAME//\//-}"
git cherry-pick $commit
git push origin HEAD:$branch
gh pr create --title "[$GITHUB_REF_NAME] $title" \
--body "Clean cherry-pick of #$NUMBER to the \`$GITHUB_REF_NAME\` branch." \
--head $branch \
--base $GITHUB_REF_NAME