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
|
2024-05-24 17:52:38 +00:00
|
|
|
container: hashicorpdev/backport-assistant:0.4.1
|
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 }}
|
2024-05-08 17:55:28 +00:00
|
|
|
ENABLE_VERSION_MANIFESTS: true
|
|
|
|
backport-ent:
|
|
|
|
if: github.event.pull_request.merged && contains(join(github.event.pull_request.labels.*.name), 'backport/ent')
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Trigger backport for Enterprise
|
|
|
|
uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
|
|
|
|
repository: hashicorp/consul-enterprise
|
|
|
|
event-type: ent-backport
|
|
|
|
client-payload: ${{ toJson(github.event) }}
|
2023-05-09 18:28:34 +00:00
|
|
|
handle-failure:
|
|
|
|
needs:
|
|
|
|
- backport
|
2024-05-08 17:55:28 +00:00
|
|
|
- backport-ent
|
|
|
|
if: always() && (needs.backport.result == 'failure' || needs.backport-ent.result == 'failure')
|
2023-05-09 18:28:34 +00:00
|
|
|
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"
|
2024-05-08 17:55:28 +00:00
|
|
|
|