-
Notifications
You must be signed in to change notification settings - Fork 10
130 lines (129 loc) · 4.18 KB
/
cmo-make-targets.yaml
File metadata and controls
130 lines (129 loc) · 4.18 KB
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
120
121
122
123
124
125
126
127
128
129
130
name: cluster-monitoring-operator make targets
on:
workflow_call:
inputs:
go-version:
description: go version
required: true
type: string
pr-title:
description: Pull request title.
required: true
type: string
pr-body:
description: Pull request body.
required: true
type: string
make-targets:
description: List of make targets to be executed sequentially.
required: true
type: string
secrets:
cloner-app-id:
description: Github ID of cloner app
required: true
cloner-app-private-key:
description: Github private key of cloner app
required: true
pr-app-id:
description: Github ID of PR creation app
required: true
pr-app-private-key:
description: Github private key of PR creation app
required: true
slack-webhook-url:
description: Slack webhook URL to send notification
required: true
env:
USER: 'github-actions[bot]<github-actions[bot]@users.noreply.github.com>'
jobs:
execute-make-targets:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: openshift/cluster-monitoring-operator
ref: master
- uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}
- name: Execute make targets - ${{ inputs.make-targets }}
run: make ${{ inputs.make-targets }}
- name: Ignore if change is only in jsonnetfile.lock.json
run: |
# Reset jsonnetfile.lock.json if no dependencies were updated
changedFiles=$(git diff --name-only | grep -cv 'jsonnetfile.lock.json')
if [[ "$changedFiles" -eq 0 ]]; then
git checkout -- jsonnet/jsonnetfile.lock.json;
fi
- name: get pr creation app token
id: pr
uses: getsentry/action-github-app-token@v1
with:
app_id: ${{ secrets.pr-app-id }}
private_key: ${{ secrets.pr-app-private-key }}
scope: openshift
- name: get cloner app token
id: cloner
uses: getsentry/action-github-app-token@v1
with:
app_id: ${{ secrets.cloner-app-id }}
private_key: ${{ secrets.cloner-app-private-key }}
scope: rhobs
- name: Find branch name
id: branch
run: |
echo "sandbox=$(echo ${{ inputs.make-targets }} | sed 's/ /-/g')" >> "$GITHUB_OUTPUT"
- name: Create Pull Request
id: create-pr
uses: rhobs/create-pull-request@v3
with:
commit-message: ${{ inputs.pr-title }}
title: ${{ inputs.pr-title }}
body: ${{ inputs.pr-body }}
author: ${{ env.USER }}
committer: ${{ env.USER }}
signoff: true
branch: automated-updates-master-${{ steps.branch.outputs.sandbox }}
delete-branch: true
token: ${{ steps.pr.outputs.token }}
push-to-fork: rhobs/cluster-monitoring-operator
push-to-fork-token: ${{ steps.cloner.outputs.token }}
- name: Compose slack message body
id: slack-message
run: |
if [ "${{ steps.create-pr.outputs.pull-request-url }}" == "" ]; then
echo "message=No changes detected." >> "$GITHUB_OUTPUT"
else
echo "message=PR ${{ steps.create-pr.outputs.pull-request-url }} has been ${{ steps.create-pr.outputs.pull-request-operation || 'updated' }}." >> "$GITHUB_OUTPUT"
fi
- uses: 8398a7/action-slack@v3
continue-on-error: true
if: success()
with:
status: custom
fields: workflow
custom_payload: |
{
attachments: [{
color: 'good',
text: `${process.env.AS_WORKFLOW}\n ${{ steps.slack-message.outputs.message }}`,
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.slack-webhook-url }}
- uses: 8398a7/action-slack@v3
continue-on-error: true
if: failure()
with:
status: custom
fields: workflow
custom_payload: |
{
attachments: [{
color: 'danger',
text: `${process.env.AS_WORKFLOW} has failed.`,
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.slack-webhook-url }}