-
Notifications
You must be signed in to change notification settings - Fork 14
108 lines (106 loc) · 5.49 KB
/
raise-operator-pr.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: Raise PR to Operator Hub community and prod repos
on:
workflow_dispatch:
inputs:
tag:
description: "current tag: The tag for this release"
required: true
default: v0.1.0-rc.2
commit_ref:
description: "commit ref: The branch or tag of the commit to use for the release."
required: false
default: main
jobs:
build_bundle_and_raise_pr:
name: Build the latest bundle and raise 2 PRs
runs-on: ubuntu-latest
steps:
- name: checkout-the-current-repo
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.commit_ref }}
- name: install-yq
run: |
echo "installing yq..."
curl -L https://github.com/mikefarah/yq/releases/download/v4.13.5/yq_linux_amd64 -o /usr/local/bin/yq && chmod +x /usr/local/bin/yq
echo "yq installed"
- id: get_channel
uses: actions/github-script@v6
with:
result-encoding: string
script: |
const version = '${{ github.event.inputs.tag }}';
return /^v\d+\.\d+\.\d+-\w+/.test(version) ? 'prerelease' : 'stable';
- name: build the operator bundle and save to temp directory
run: |
cd operator/ || exit 1
VERSION='${{ github.event.inputs.tag }}' CHANNELS='${{ steps.get_channel.outputs.result }}' DEFAULT_CHANNEL='stable' make bundle
echo 'copy-bundle-into-tmp'
cp -r bundle/ /tmp/bundle-operator-move2kube
cp bundle.Dockerfile /tmp/bundle.Dockerfile
- name: cleanup
run: rm -rf {*,.*} || true
- name: checkout-the-move2kube-fork-of-upstream-repo
shell: bash
run: |
git clone 'https://move2kube:${{ secrets.MOVE2KUBE_PATOKEN }}@github.com/move2kube/community-operators'
cd community-operators/ || exit 1
git checkout main
git config user.name move2kube
git config user.email move2kube@gmail.com
echo 'sync our fork with upstream'
git remote add upstream https://github.com/k8s-operatorhub/community-operators
git fetch --all
git reset --hard upstream/main
echo 'copy-bundle-into-fork-creating-new-version-dir'
cd operators/move2kube-operator/ || exit 1
VERSION='${{ github.event.inputs.tag }}'
VERSION_WITHOUT_V="${VERSION#v}"
cp -r /tmp/bundle-operator-move2kube "${VERSION_WITHOUT_V}" && cp /tmp/bundle.Dockerfile "${VERSION_WITHOUT_V}"/bundle.Dockerfile
echo 'make a commit and push to our fork'
# https://stackoverflow.com/questions/67789507/generate-unique-string-in-github-actions
BRANCH_NAME='feat-${{ github.event.inputs.tag }}-${{ github.run_id }}-${{ github.run_attempt }}'
git checkout -b "${BRANCH_NAME}"
git add -A
git commit -s -m 'operator move2kube-operator (${{ github.event.inputs.tag }})'
git push -u origin "${BRANCH_NAME}"
echo 'create-pull-request-to-community-repo'
curl -L \
-X POST \
-H 'Accept: application/vnd.github+json' \
-H 'Authorization: Bearer ${{ secrets.MOVE2KUBE_PATOKEN }}' \
-H 'X-GitHub-Api-Version: 2022-11-28' \
https://api.github.com/repos/k8s-operatorhub/community-operators/pulls \
-d '{"title":"operator move2kube-operator (${{ github.event.inputs.tag }})","body":"An automated PR to update move2kube-operator to ${{ github.event.inputs.tag }}","head":"move2kube:'"${BRANCH_NAME}"'","base":"main"}'
- name: checkout-the-move2kube-fork-of-the-prod-upstream-repo
shell: bash
run: |
git clone 'https://move2kube:${{ secrets.MOVE2KUBE_PATOKEN }}@github.com/move2kube/community-operators-prod'
cd community-operators-prod/ || exit 1
git checkout main
git config user.name move2kube
git config user.email move2kube@gmail.com
echo 'sync our fork with upstream'
git remote add upstream https://github.com/redhat-openshift-ecosystem/community-operators-prod
git fetch --all
git reset --hard upstream/main
echo 'copy-bundle-into-fork-of-prod-repo-creating-new-version-dir'
cd operators/move2kube-operator/ || exit 1
VERSION='${{ github.event.inputs.tag }}'
VERSION_WITHOUT_V="${VERSION#v}"
cp -r /tmp/bundle-operator-move2kube "${VERSION_WITHOUT_V}" && cp /tmp/bundle.Dockerfile "${VERSION_WITHOUT_V}"/bundle.Dockerfile
echo 'make a commit and push to our fork'
# https://stackoverflow.com/questions/67789507/generate-unique-string-in-github-actions
BRANCH_NAME='feat-${{ github.event.inputs.tag }}-${{ github.run_id }}-${{ github.run_attempt }}'
git checkout -b "${BRANCH_NAME}"
git add -A
git commit -s -m 'operator move2kube-operator (${{ github.event.inputs.tag }})'
git push -u origin "${BRANCH_NAME}"
echo 'create-pull-request-to-prod-repo'
curl -L \
-X POST \
-H 'Accept: application/vnd.github+json' \
-H 'Authorization: Bearer ${{ secrets.MOVE2KUBE_PATOKEN }}' \
-H 'X-GitHub-Api-Version: 2022-11-28' \
https://api.github.com/repos/redhat-openshift-ecosystem/community-operators-prod/pulls \
-d '{"title":"operator move2kube-operator (${{ github.event.inputs.tag }})","body":"An automated PR to update move2kube-operator to ${{ github.event.inputs.tag }}","head":"move2kube:'"${BRANCH_NAME}"'","base":"main"}'