-
Notifications
You must be signed in to change notification settings - Fork 17
121 lines (106 loc) · 4.84 KB
/
release-generate-ci-template.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
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
name: Generate CI config (template)
on:
pull_request:
branches:
- '**'
push:
branches:
- 'main'
schedule:
- cron: "0 6 * * 1" # Runs every Monday at 6:00 AM UTC
workflow_dispatch: # Manual workflow trigger
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
generate-ci:
name: generate-ci
runs-on: ubuntu-latest
steps:
- name: Checkout openshift-knative/hack
uses: actions/checkout@v4
with:
path: ./src/github.com/openshift-knative/hack
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version-file: ./src/github.com/openshift-knative/hack/go.mod
- name: Install yq
run: go install github.com/mikefarah/yq/v3@latest
- name: Install skopeo
run: go install -tags="exclude_graphdriver_btrfs containers_image_openpgp" github.com/containers/skopeo/cmd/[email protected]
- name: Install YAML2JSON
run: go install github.com/bronze1man/yaml2json@latest
- name: Convert configurations to JSON
working-directory: ./src/github.com/openshift-knative/hack
run: find config/*.yaml | xargs -I{} sh -c "yaml2json < {} > {}.json"
- name: Checkout openshift/release
if: ${{ github.event_name == 'pull_request' }}
uses: actions/checkout@v4
with:
ref: 'master'
repository: 'openshift/release'
path: ./src/github.com/openshift-knative/hack/openshift/release
- name: Checkout openshift/release
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && github.ref_name == 'main' }}
uses: actions/checkout@v4
with:
ref: 'master'
repository: 'openshift/release'
path: ./src/github.com/openshift-knative/hack/openshift/release
token: ${{ secrets.SERVERLESS_QE_ROBOT }}
- name: Configure Git user
run: |
git config --global user.email "[email protected]"
git config --global user.name "serverless-qe"
- name: Generate CI
working-directory: ./src/github.com/openshift-knative/hack
run: make generate-ci-no-clean ARGS=--branch=master
- name: Create Pull Request - openshift/release
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && github.ref_name == 'main' }}
env:
GH_TOKEN: ${{ secrets.SERVERLESS_QE_ROBOT }}
GITHUB_TOKEN: ${{ secrets.SERVERLESS_QE_ROBOT }}
run: |
set -x
git remote add fork "https://github.com/serverless-qe/release.git"
branch="sync-serverless-ci"
remote_exists=$(git ls-remote --heads fork "$branch")
if [ -z "$remote_exists" ]; then
# remote doesn't exist.
git push "https://serverless-qe:${GH_TOKEN}@github.com/serverless-qe/release.git" "$branch:$branch" -f || exit 1
fi
git fetch fork "$branch"
if git diff --quiet "fork/$branch" "$branch"; then
echo "Branches are identical. No need to force push."
else
git push "https://serverless-qe:${GH_TOKEN}@github.com/serverless-qe/release.git" "$branch:$branch" -f
fi
gh pr create --base master --head "serverless-qe:$branch" --fill-verbose || true
working-directory: ./src/github.com/openshift-knative/hack/openshift/release
- name: Create Pull Request - openshift-knative/hack
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && github.ref_name == 'main' }}
env:
GH_TOKEN: ${{ secrets.SERVERLESS_QE_ROBOT }}
GITHUB_TOKEN: ${{ secrets.SERVERLESS_QE_ROBOT }}
run: |
set -x
git remote add fork "https://github.com/serverless-qe/hack.git"
branch="sync-konflux-main"
remote_exists=$(git ls-remote --heads fork "$branch")
if [ -z "$remote_exists" ]; then
# remote doesn't exist.
git push "https://serverless-qe:${GH_TOKEN}@github.com/serverless-qe/hack.git" "$branch:$branch" -f || exit 1
fi
git fetch fork "$branch"
if git diff --quiet "fork/$branch" "$branch"; then
echo "Branches are identical. No need to force push."
else
git push "https://serverless-qe:${GH_TOKEN}@github.com/serverless-qe/hack.git" "$branch:$branch" -f
fi
gh pr create --base main --head "serverless-qe:$branch" --title "[main] Add Konflux configurations" --body "Add Konflux components and pipelines" || true
# Use the repository cloned by the prowgen tool
working-directory: ./src/github.com/openshift-knative/hack/openshift-knative/hack