2022-04-28 21:23:39 +00:00
|
|
|
# This action creates downstream PRs for PRs with backport labels defined.
|
|
|
|
# See docs here: https://github.com/hashicorp/backport-assistant
|
|
|
|
|
|
|
|
name: Backport Assistant Runner
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request_target:
|
|
|
|
types:
|
|
|
|
- closed
|
|
|
|
- labeled
|
2022-05-06 19:38:02 +00:00
|
|
|
branches:
|
|
|
|
- main
|
2022-05-19 14:01:57 +00:00
|
|
|
- 'release/*.*.x'
|
2022-04-28 21:23:39 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
backport:
|
|
|
|
if: github.event.pull_request.merged
|
|
|
|
runs-on: ubuntu-latest
|
2022-11-28 18:21:04 +00:00
|
|
|
container: hashicorpdev/backport-assistant:0.3.0
|
2022-04-28 21:23:39 +00:00
|
|
|
steps:
|
|
|
|
- name: Run Backport Assistant for stable-website
|
|
|
|
run: |
|
2022-11-28 18:21:04 +00:00
|
|
|
backport-assistant backport -merge-method=squash -gh-automerge
|
2022-04-28 21:23:39 +00:00
|
|
|
env:
|
2022-05-03 18:24:05 +00:00
|
|
|
BACKPORT_LABEL_REGEXP: "type/docs-(?P<target>cherrypick)"
|
2022-04-28 21:23:39 +00:00
|
|
|
BACKPORT_TARGET_TEMPLATE: "stable-website"
|
2022-08-30 19:44:06 +00:00
|
|
|
BACKPORT_MERGE_COMMIT: true
|
2022-04-28 21:23:39 +00:00
|
|
|
GITHUB_TOKEN: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
|
2022-05-06 19:38:02 +00:00
|
|
|
- name: Backport changes to latest release branch
|
|
|
|
run: |
|
2022-05-19 20:08:11 +00:00
|
|
|
# Use standard token here
|
|
|
|
resp=$(curl -f -s -H 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' "https://api.github.com/repos/$GITHUB_REPOSITORY/labels?per_page=100")
|
2022-05-06 19:38:02 +00:00
|
|
|
ret="$?"
|
|
|
|
if [[ "$ret" -ne 0 ]]; then
|
|
|
|
echo "The GitHub API returned $ret"
|
|
|
|
exit $ret
|
|
|
|
fi
|
|
|
|
# get the latest backport label excluding any website labels, ex: `backport/0.3.x` and not `backport/website`
|
|
|
|
latest_backport_label=$(echo "$resp" | jq -r '.[] | select(.name | (startswith("backport/") and (contains("website") | not))) | .name' | sort -rV | head -n1)
|
|
|
|
echo "Latest backport label: $latest_backport_label"
|
|
|
|
# set BACKPORT_TARGET_TEMPLATE for backport-assistant
|
|
|
|
# trims backport/ from the beginning with parameter substitution
|
|
|
|
export BACKPORT_TARGET_TEMPLATE="release/${latest_backport_label#backport/}.x"
|
2022-11-28 18:21:04 +00:00
|
|
|
backport-assistant backport -merge-method=squash -gh-automerge
|
2022-05-06 19:38:02 +00:00
|
|
|
env:
|
|
|
|
BACKPORT_LABEL_REGEXP: "type/docs-(?P<target>cherrypick)"
|
|
|
|
GITHUB_TOKEN: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
|
2022-04-28 21:23:39 +00:00
|
|
|
- name: Run Backport Assistant for release branches
|
|
|
|
run: |
|
2022-11-28 18:21:04 +00:00
|
|
|
backport-assistant backport -merge-method=squash -gh-automerge
|
2022-04-28 21:23:39 +00:00
|
|
|
env:
|
2022-05-03 16:33:56 +00:00
|
|
|
BACKPORT_LABEL_REGEXP: "backport/(?P<target>\\d+\\.\\d+)"
|
2022-04-28 21:23:39 +00:00
|
|
|
BACKPORT_TARGET_TEMPLATE: "release/{{.target}}.x"
|
|
|
|
GITHUB_TOKEN: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
|