-
Notifications
You must be signed in to change notification settings - Fork 69
86 lines (75 loc) · 3.17 KB
/
validate-release-promotion.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
---
name: Validate Release Promotion
on:
pull_request:
branches:
- 'release-**'
jobs:
promotion:
if: ${{ github.event_name == 'pull_request' && contains(github.base_ref, 'release-') }}
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}
steps:
- name: Setup Golang
uses: openshift-knative/hack/actions/setup-go@main
- name: Install yq
run: |
go install github.com/mikefarah/yq/v3@latest
- name: Checkout
uses: actions/checkout@v4
with:
path: ./src/github.com/openshift-knative/serverless-operator
fetch-depth: 0
- name: Merge upstream
if: github.event_name == 'pull_request'
working-directory: ./src/github.com/openshift-knative/serverless-operator
run: |
if ! git config user.name > /dev/null; then
git config user.name "John Doe"
fi
if ! git config user.email > /dev/null; then
git config user.email "johndoe@localhost"
fi
git remote add upstream https://github.com/openshift-knative/serverless-operator.git
git pull --no-rebase upstream ${{ github.base_ref }}
shell: bash
- name: Checkout openshift/release
uses: actions/checkout@v4
with:
branch: 'master'
repository: 'openshift/release'
path: ./src/github.com/openshift/release
- name: Verify promotion tag or name in openshift/release
working-directory: ./src/github.com/openshift/release
shell: bash
run: |
tag="release-$(yq read ../../openshift-knative/serverless-operator/olm-catalog/serverless-operator/project.yaml 'project.version')"
release=${{ github.base_ref }}
count=0
while IFS= read -r -d '' file
do
promotion_name=$(yq r "$file" 'promotion.to[0].name')
if [ "$promotion_name" != "" ] && [ "$promotion_name" != "${tag}" ]; then
count=$(( count + 1 ))
echo "File: $file"
echo "promotion.to[0].name: $promotion_name"
echo
fi
promotion_tag=$(yq r "$file" 'promotion.to[0].tag')
if [ "$promotion_tag" != "" ] && [ "$promotion_tag" != "${tag}" ]; then
count=$(( count + 1 ))
echo "File: $file"
echo "promotion.to[0].name: $promotion_tag"
echo
fi
done < <(find ci-operator/config/openshift-knative/serverless-operator -type f -name "*${release}*" -print0)
if [ $count -ne 0 ]; then
echo "## $count files with an unexpected promotion name or tag"
echo "1. Use the [release-generate-ci](https://github.com/openshift-knative/serverless-operator/actions/workflows/release-generate-ci.yaml?query=branch%3A${release}) GH actions workflow in serverless-operator on the $release branch with inputs:"
echo " - **use workflow from**: **$release**"
echo " - **branch**: **$release**"
echo " - **tag**: **$tag**"
echo "2. merge the created PR in openshift/release"
exit 1
fi