open-consul/.github/workflows/backport-assistant.yml
hc-github-team-consul-core 65b3b25948
Backport of Fix Backport Assistant PR commenting into release/1.16.x (#18203)
* backport of commit de63f65b1c4f605c4529f38763cd1e15ad94e082

* backport of commit f6c0fff6cea9afd69e323a9454a54eb7299eef05

---------

Co-authored-by: Michael Zalimeni <michael.zalimeni@hashicorp.com>
2023-07-20 16:14:15 +00:00

44 lines
1.4 KiB
YAML

# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
# 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
branches:
- main
- 'release/*.*.x'
jobs:
backport:
if: github.event.pull_request.merged
runs-on: ubuntu-latest
container: hashicorpdev/backport-assistant:0.3.4
steps:
- name: Run Backport Assistant for release branches
run: |
backport-assistant backport -merge-method=squash -gh-automerge
env:
BACKPORT_LABEL_REGEXP: "backport/(?P<target>\\d+\\.\\d+)"
BACKPORT_TARGET_TEMPLATE: "release/{{.target}}.x"
GITHUB_TOKEN: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
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}\"}" \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${{ github.event.pull_request.number }}/comments"