-
Notifications
You must be signed in to change notification settings - Fork 3.5k
108 lines (95 loc) · 3.77 KB
/
operator-reusable-hub-release.yml
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
name: Reusable - Create operator hub pull request
on:
workflow_call:
inputs:
org:
type: string
required: true
repo:
type: string
required: true
secrets:
GRAFANABOT_GITHUB_TOKEN:
required: true
jobs:
create-operator-pull-request:
runs-on: ubuntu-latest
steps:
- name: Set redhat-openshift-ecosystem specific variables
if: ${{ inputs.org == 'redhat-openshift-ecosystem' }}
env:
ocpDir: '-openshift'
ocpSupportedVersions: 'v4.12'
run: |
echo "ocpDir=${ocpDir}" >> $GITHUB_ENV
echo "ocpSupportedVersions=${ocpSupportedVersions}" >> $GITHUB_ENV
- name: Set version as env variable
env:
TAG: ${{ github.ref_name }}
run: |
echo $TAG
TAG=${TAG:10} # remove "operator/v" (prefix)
echo version=${TAG} >> $GITHUB_ENV # update GitHub ENV vars
- name: Sync fork
env:
GH_TOKEN: ${{ secrets.GRAFANABOT_GITHUB_TOKEN }}
run: |
# synchronizing the fork is fast, and avoids the need to fetch the full upstream repo
# (fetching the upstream repo with "--depth 1" would lead to "shallow update not allowed"
# error when pushing back to the origin repo)
gh repo sync grafanabot/${{ inputs.repo }} \
--source ${{ inputs.org }}/${{ inputs.repo }} \
--force
- name: Checkout operatorhub repo
uses: actions/checkout@v4
with:
repository: grafanabot/${{ inputs.repo }}
token: ${{ secrets.GRAFANABOT_GITHUB_TOKEN }}
- name: Checkout loki to tmp/ directory
uses: actions/checkout@v4
with:
repository: grafana/loki
token: ${{ secrets.GRAFANABOT_GITHUB_TOKEN }}
path: tmp/
- name: Update version
env:
VERSION: ${{ env.version }}
OCP_DIR: ${{ env.ocpDir || ''}}
run: |
mkdir operators/loki-operator/${VERSION}
cp -R ./tmp/operator/bundle/community${OCP_DIR}/* operators/loki-operator/${VERSION}
rm -f "operators/loki-operator/${VERSION}/bundle.Dockerfile"
rm -rf ./tmp
- name: Add OpenShift Supported versions to redhat catalog
if: ${{ inputs.org == 'redhat-openshift-ecosystem' }}
uses: fjogeleit/yaml-update-action@main
with:
valueFile: "operators/loki-operator/${{ env.version }}/metadata/annotations.yaml"
propertyPath: "annotations['com.redhat.openshift.versions']"
value: ${{ env.ocpSupportedVersions }}
commitChange: false
- name: Use CLA approved github bot
run: |
git config user.name grafanabot
git config user.email [email protected]
- name: Create pull request against ${{ inputs.org }}/${{ inputs.repo }}
env:
VERSION: ${{ env.version }}
GH_TOKEN: ${{ secrets.GRAFANABOT_GITHUB_TOKEN }}
run: |
message="Update the loki-operator to $VERSION"
body="Release loki-operator \`$VERSION\`.
cc @periklis @xperimental @JoaoBraveCoding @btaani @shwetaap
"
branch="update-loki-operator-to-${VERSION}"
# gh pr create doesn't have a way to explicitly specify different head and base
# repositories currently, but it will implicitly pick up the head from a different
# repository if you set up a tracking branch
git checkout -b $branch
git add -A
git commit -s -m "$message"
git push -f --set-upstream origin $branch
gh pr create --title "$message" \
--body "$body" \
--repo ${{ inputs.org }}/${{ inputs.repo }} \
--base main