-
Notifications
You must be signed in to change notification settings - Fork 152
54 lines (48 loc) · 1.78 KB
/
Copy pathbackport.yml
File metadata and controls
54 lines (48 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# SPDX-FileCopyrightText: 2026 Oak Ridge National Laboratory and Contributors
#
# SPDX-License-Identifier: Apache-2.0
name: Backport PR
on:
workflow_dispatch:
inputs:
pr:
description: Pull Request number
required: true
target_branch:
description: Branch to backport to
required: true
permissions: {}
jobs:
backport:
environment: backport
runs-on: ubuntu-latest
name: Backport
env:
GH_TOKEN: ${{ secrets.BACKPORT_TOKEN }}
BRANCH: ${{ github.event.inputs.target_branch }}
PR: ${{ github.event.inputs.pr }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v4
with:
fetch-depth: 0
token: ${{ secrets.BACKPORT_TOKEN }}
- name: Create backport
run: |
commit_hash=$(gh pr view "${PR}" --repo ornladios/ADIOS2 --json mergeCommit --jq '.mergeCommit.oid')
if [ -z "$commit_hash" ] || [ "$commit_hash" = "null" ]; then
echo "Error: PR ${PR} is not merged yet"
exit 1
fi
git config user.name "ornladios-robot"
git config user.email "ornladios-robot[bot]@users.noreply.github.com"
gh auth setup-git
git checkout --track "origin/${BRANCH}"
git checkout -b "backport-to-${BRANCH}-${PR}"
gh pr view --json commits --jq '.commits[].oid' "${PR}" | xargs -n1 git cherry-pick --mainline 1 -x
git push -f https://github.com/ornladios-robot/ADIOS2.git "backport-to-${BRANCH}-${PR}"
gh api repos/ornladios/ADIOS2/pulls \
--method POST \
-f head="ornladios-robot:backport-to-${BRANCH}-${PR}" \
-f base="${BRANCH}" \
-f title="Backport #${PR} to ${BRANCH}" \
-f body="Backports #${PR}"