2023-03-22 13:17:19 +00:00
|
|
|
# Copyright (c) HashiCorp, Inc.
|
|
|
|
# SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
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
|
2023-05-26 16:33:04 +00:00
|
|
|
container: hashicorpdev/backport-assistant:0.3.4
|
2022-04-28 21:23:39 +00:00
|
|
|
steps:
|
|
|
|
- name: Run Backport Assistant for release branches
|
|
|
|
run: |
|
2023-11-20 16:51:39 +00:00
|
|
|
backport-assistant backport -merge-method=squash
|
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 }}
|
2023-05-09 18:28:34 +00:00
|
|
|
handle-failure:
|
|
|
|
needs:
|
|
|
|
- backport
|
|
|
|
if: always() && needs.backport.result == 'failure'
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Comment on PR
|
|
|
|
run: |
|
|
|
|
github_message="Backport failed @${{ github.event.sender.login }}. Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
|
|
|
curl -s -H "Authorization: token ${{ secrets.PR_COMMENT_TOKEN }}" \
|
|
|
|
-X POST \
|
|
|
|
-d "{ \"body\": \"${github_message}\"}" \
|
2023-07-20 15:39:01 +00:00
|
|
|
"https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${{ github.event.pull_request.number }}/comments"
|