Skip to content

Commit 30fd9a3

Browse files
committed
refactor
Signed-off-by: Coleen Iona Quadros <[email protected]>
1 parent e00c150 commit 30fd9a3

File tree

2 files changed

+74
-32
lines changed

2 files changed

+74
-32
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Check Konflux PRs in Downstream Repos
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * 1' #@weekly
7+
8+
jobs:
9+
check-konflux-prs:
10+
runs-on: ubuntu-latest
11+
# get secrets as input
12+
secrets:
13+
pr-app-id: ${{ secrets.ACM_APP_ID }}
14+
pr-app-private-key: ${{ secrets.ACM_APP_PRIVATE_KEY }}
15+
slack-webhook-url: ${{ secrets.ACM_SLACK_WEBHOOK_URL }}
16+
strategy:
17+
matrix:
18+
repo:
19+
- stolostron/thanos
20+
- stolostron/node-exporter
21+
- stolostron/kube-state-metrics
22+
- stolostron/prometheus
23+
- stolostron/prometheus-alertmanager
24+
- stolostron/prometheus-operator
25+
- stolostron/grafana
26+
- stolosstron/kube-rbac-proxy
27+
- stolostron/multicluster-observability-operator
28+
- stolostron/observatorium
29+
- stolostron/observatorium-operator
30+
- stolotstron/thanos-receive-controller
31+
- stolostron/kube-thanos
32+
33+
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@v2
36+
- name: Get auth token to create pull request for ${{ matrix.repo }}
37+
if: github.event_name != 'pull_request'
38+
id: pr
39+
uses: getsentry/action-github-app-token@v3
40+
with:
41+
app_id: ${{ secrets.pr-app-id }}
42+
private_key: ${{ secrets.pr-app-private-key }}
43+
scope: ${{ matrix.repo }}
44+
- name: List PRs and check for Konflux
45+
env:
46+
GH_TOKEN: ${{ steps.pr.outputs.token }}
47+
id: check-prs
48+
run: |
49+
PR_URL=$(gh pr list --repo ${{ matrix.repo }} --state open --search "Konflux in:title" --json url --jq '.[].url')
50+
if [ -n "$PR_URL" ]; then
51+
echo "konflux_pr_exists=1" >> $GITHUB_ENV
52+
echo "PR_URL=$PR_URL" >> $GITHUB_ENV
53+
else
54+
echo "konflux_pr_exists=0" >> $GITHUB_ENV
55+
echo "PR_URL=" >> $GITHUB_ENV
56+
fi
57+
- name: Compose Slack message
58+
id: slack-message
59+
run: |
60+
if [ "${{ env.konflux_pr_exists }}" == "1" ]; then
61+
echo "message=Unmerged Konflux PRs are present in https://github.com/${{ matrix.repo }}" >> $GITHUB_ENV
62+
- name: Send Slack notification
63+
uses: 8398a7/action-slack@v3
64+
with:
65+
status: custom
66+
fields: workflow
67+
custom_payload: |
68+
{
69+
attachments: [{
70+
color: ${{ env.konflux_pr_exists == '1' && 'danger' || 'good' }},
71+
text: "**${{ env.message }}**",
72+
}]
73+
env:
74+
SLACK_WEBHOOK_URL: ${{ secrets.ACM_SLACK_WEBHOOK_URL }}

.github/workflows/merge-acm-flow.yaml

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -261,19 +261,6 @@ jobs:
261261
echo "pr_exists=0" >> $GITHUB_OUTPUT
262262
fi
263263
fi
264-
- name: Check if Konflux PRs exist
265-
env:
266-
GH_TOKEN: ${{ steps.pr.outputs.token }}
267-
id: konflux-pr-exists
268-
if: github.event_name != 'pull_request' && failure()
269-
run: |
270-
PR_URL=$(gh pr list --repo ${{ inputs.downstream }} --state open | grep -i konflux)
271-
echo "PR_URL=$PR_URL"
272-
if [ ! -z "$PR_URL" ]; then
273-
echo "konflux_pr_exists=1" >> $GITHUB_OUTPUT
274-
else
275-
echo "konflux_pr_exists=0" >> $GITHUB_OUTPUT
276-
fi
277264
- name: Compose slack message body
278265
if: github.event_name != 'pull_request' && (success() || steps.fork-sync.outputs.status == 'uptodate' || steps.fork-sync.outputs.status == 'ahead' || steps.pr-exists.outputs.pr_exists == '1' )
279266
continue-on-error: true
@@ -289,10 +276,6 @@ jobs:
289276
else
290277
echo "message=PR $PR_URL has been ${{ steps.create-pr.outputs.pull-request-operation || 'updated' }}." >> $GITHUB_OUTPUT
291278
fi
292-
echo "konflux pr exists: ${{ steps.konflux-pr-exists.outputs.konflux_pr_exists }}"
293-
if [ "${{ steps.konflux-pr-exists.outputs.konflux_pr_exists }}" == "1" ]; then
294-
echo "konflux_message=Unmerged Konflux PRs are present in ${{ inputs.downstream }}." >> $GITHUB_OUTPUT
295-
fi
296279
- uses: 8398a7/action-slack@v3
297280
if: github.event_name != 'pull_request' && (success() || steps.fork-sync.outputs.status == 'uptodate' || steps.fork-sync.outputs.status == 'ahead' || steps.pr-exists.outputs.pr_exists == '1')
298281
continue-on-error: true
@@ -308,21 +291,6 @@ jobs:
308291
}
309292
env:
310293
SLACK_WEBHOOK_URL: ${{ secrets.slack-webhook-url }}
311-
- uses: 8398a7/action-slack@v3
312-
if: github.event_name != 'pull_request' && (success() || steps.pr-exists.outputs.pr_exists == '1') && steps.konflux-pr-exists.outputs.konflux_pr_exists == '1'
313-
continue-on-error: true
314-
with:
315-
status: custom
316-
fields: workflow
317-
custom_payload: |
318-
{
319-
attachments: [{
320-
color: 'danger',
321-
text: `**${process.env.AS_WORKFLOW}\n ${{ steps.slack-message.outputs.konflux_message }}**`,
322-
}]
323-
}
324-
env:
325-
SLACK_WEBHOOK_URL: ${{ secrets.slack-webhook-url }}
326294
- uses: 8398a7/action-slack@v3
327295
if: github.event_name != 'pull_request' && (failure() && steps.fork-sync.outputs.status != 'uptodate' && steps.fork-sync.outputs.status != 'ahead' && !(steps.pr-exists.outputs.pr_exists == '1'))
328296
continue-on-error: true

0 commit comments

Comments
 (0)