-
Notifications
You must be signed in to change notification settings - Fork 5
119 lines (108 loc) · 4.29 KB
/
fbc-insta-merge.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Insta Merge FBC Nudges
on:
pull_request:
branches:
- 'rhoai-2.1[6-9]+' # Trigger the workflow on pushes to any rhoai-2.16 branch
types:
- opened
- reopened
- edited
paths:
- catalog/catalog-patch.yaml
- schedule/catalog-github-trigger.txt
env:
GITHUB_ORG: red-hat-data-services
GITHUB_RKA_ORG: rhoai-rhtap
RESOLVE_CONFLICTS_FOR: 'catalog/catalog-patch.yaml,schedule/catalog-github-trigger.txt'
permissions:
contents: write
pull-requests: write
checks: write
security-events: write
statuses: write
jobs:
insta-merge:
if: ${{ github.event.sender.login == 'konflux-internal-p02[bot]' && contains(github.event.pull_request.title, 'update odh-operator-bundle-')}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
- name: List all changed files
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
echo $ALL_CHANGED_FILES
for file in ${ALL_CHANGED_FILES}; do
echo "$file was changed"
done
- name: Merge Feasibility Check
if: ${{ steps.changed-files.outputs.all_changed_files == 'catalog/catalog-patch.yaml' || steps.changed-files.outputs.all_changed_files == 'schedule/catalog-github-trigger.txt' }}
id: merge-feasibility-check
run: |
# Declare variables
BASE_BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}
HEAD_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
VERSION=v${BASE_BRANCH/rhoai-/}
SUFFIX=${VERSION/./-}
echo "SUFFIX=$SUFFIX"
echo "HEAD_BRANCH=$HEAD_BRANCH"
TITLE="${{ github.event.pull_request.title }}"
if [[ $TITLE == chore\(deps\)* ]]
then
TITLE=${TITLE/chore\(deps\): u/U}
fi
REGEX="^Update.*-$SUFFIX to [0-9a-z]{1,40}$"
FEASIBLE=No
#Check if PR title is as per the convention
if [[ "$TITLE" =~ $REGEX ]]
then
FEASIBLE=Yes
echo "It's a valid PR to merge!"
else
echo "Insta-merge not configured to merge this PR, skipping."
fi
echo "FEASIBLE=$FEASIBLE" >> $GITHUB_OUTPUT
echo "BASE_BRANCH=$BASE_BRANCH" >> $GITHUB_OUTPUT
echo "HEAD_BRANCH=$HEAD_BRANCH" >> $GITHUB_OUTPUT
- name: Generate github-app token
id: app-token
uses: getsentry/action-github-app-token@v2
with:
app_id: ${{ secrets.RHOAI_DEVOPS_APP_ID }}
private_key: ${{ secrets.RHOAI_DEVOPS_APP_PRIVATE_KEY }}
- uses: Wandalen/[email protected]
if: ${{ steps.merge-feasibility-check.outputs.FEASIBLE == 'Yes' }}
with:
action: red-hat-data-services/insta-merge@main
retry_condition: steps._this.outputs.code == 0
attempt_limit: 5
github_token: ${{ steps.app-token.outputs.token }}
with: |
upstream_repo: "https://github.com/${GITHUB_ORG}/RHOAI-Build-Config.git"
upstream_branch: "${{ steps.merge-feasibility-check.outputs.BASE_BRANCH }}"
downstream_repo: "https://github.com/${GITHUB_ORG}/RHOAI-Build-Config.git"
downstream_branch: "${{ steps.merge-feasibility-check.outputs.HEAD_BRANCH }}"
token: ${{ steps.app-token.outputs.token }}
resolve_conflicts_for: "${RESOLVE_CONFLICTS_FOR}"
merge_args: "--no-edit"
pr_url: "${{ github.event.pull_request.html_url }}"
# - name: instant-merge
# env:
# GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
# run: |
# # Declare variables
# BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}
# VERSION=v${BRANCH/rhoai-/}
# SUFFIX=${VERSION/./-}
# REGEX="^Update $COMPONENT-$SUFFIX to [0-9a-z]{1,40}$"
#
# #Check if PR title is as per the convention
# if [[ "${{ github.event.pull_request.title }}" =~ $REGEX ]]
# then
# gh pr merge --merge --admin ${{ github.event.pull_request.html_url }}
# echo "Merged!!"
# else
# echo "Insta-merge not configured to merge this PR, skipping."
# fi