Skip to content

Commit 1aca265

Browse files
authored
Splitting backport-asst GH action (#13461)
This way we can have an OSS action, and an ENT action. We'll be able to keep the backport-assistant workflows the same on OSS and ENT for normal PRs, and have a separate labeling system on OSS for docs backports. We should delete the backport-docs.yml file on ENT.
1 parent b3ab2d9 commit 1aca265

File tree

2 files changed

+47
-32
lines changed

2 files changed

+47
-32
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
name: Backport Assistant Runner For Docs (OSS only)
3+
4+
on:
5+
pull_request_target:
6+
types:
7+
- closed
8+
- labeled
9+
10+
jobs:
11+
backport-for-docs:
12+
if: github.event.pull_request.merged
13+
runs-on: ubuntu-latest
14+
container: hashicorpdev/backport-assistant:0.2.3
15+
steps:
16+
- name: Backport changes to stable-website
17+
run: |
18+
backport-assistant backport -automerge
19+
env:
20+
BACKPORT_LABEL_REGEXP: "backport/(?P<target>website)"
21+
BACKPORT_TARGET_TEMPLATE: "stable-{{.target}}"
22+
GITHUB_TOKEN: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
23+
- name: Backport changes labeled website to latest release branch
24+
run: |
25+
resp=$(curl -f -s "https://api.github.com/repos/$GITHUB_REPOSITORY/releases?per_page=100")
26+
ret="$?"
27+
if [[ "$ret" -ne 0 ]]; then
28+
echo "The GitHub API returned $ret"
29+
exit $ret
30+
fi
31+
32+
# find the latest non-rc release
33+
latest_version=$(echo "$resp" | tr '\r\n' ' ' | jq -r '.[] | select(.name|test("^v\\d+\\.\\d+\\.\\d+$")) | .name' | sort -rV | head -n1)
34+
echo "Latest non-rc version: $latest_version"
35+
36+
# strip leading "v" &
37+
target="${latest_version#v}"
38+
# replace patch version with "x"
39+
target="${target%.*}.x"
40+
41+
export BACKPORT_TARGET_TEMPLATE="release/$target"
42+
backport-assistant backport
43+
env:
44+
BACKPORT_LABEL_REGEXP: "backport/(?P<target>website)"
45+
GITHUB_TOKEN: ${{ secrets.ELEVATED_GITHUB_TOKEN }}

.github/workflows/backport.yml

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: Backport Assistant Runner
2+
name: Backport Assistant Runner (for OSS & ENT)
33

44
on:
55
pull_request_target:
@@ -8,41 +8,11 @@ on:
88
- labeled
99

1010
jobs:
11-
backport:
11+
backport-targeted-release-branch:
1212
if: github.event.pull_request.merged
1313
runs-on: ubuntu-latest
1414
container: hashicorpdev/backport-assistant:0.2.3
1515
steps:
16-
- name: Backport changes to stable-website
17-
run: |
18-
backport-assistant backport -automerge
19-
env:
20-
BACKPORT_LABEL_REGEXP: "backport/(?P<target>website)"
21-
BACKPORT_TARGET_TEMPLATE: "stable-{{.target}}"
22-
GITHUB_TOKEN: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
23-
- name: Backport changes labeled website to latest release branch
24-
run: |
25-
resp=$(curl -f -s "https://api.github.com/repos/$GITHUB_REPOSITORY/releases?per_page=100")
26-
ret="$?"
27-
if [[ "$ret" -ne 0 ]]; then
28-
echo "The GitHub API returned $ret"
29-
exit $ret
30-
fi
31-
32-
# find the latest non-rc release
33-
latest_version=$(echo "$resp" | tr '\r\n' ' ' | jq -r '.[] | select(.name|test("^v\\d+\\.\\d+\\.\\d+$")) | .name' | sort -rV | head -n1)
34-
echo "Latest non-rc version: $latest_version"
35-
36-
# strip leading "v" &
37-
target="${latest_version#v}"
38-
# replace patch version with "x"
39-
target="${target%.*}.x"
40-
41-
export BACKPORT_TARGET_TEMPLATE="release/$target"
42-
backport-assistant backport
43-
env:
44-
BACKPORT_LABEL_REGEXP: "backport/(?P<target>website)"
45-
GITHUB_TOKEN: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
4616
- name: Backport changes to targeted release branch
4717
run: |
4818
backport-assistant backport

0 commit comments

Comments
 (0)