-
Notifications
You must be signed in to change notification settings - Fork 13
175 lines (168 loc) · 6.26 KB
/
generate-catalogs.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
---
# This workflow generates the experimental catalog and pushes it to
# the publish branch.
name: generate-catalogs
on:
schedule:
- cron: "0 1 * * *"
workflow_dispatch: # allow manual triggering
jobs:
generate-experimental-catalog:
runs-on: ubuntu-latest
if: github.repository_owner == 'openshift-pipelines' # do not run this elsewhere
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/go
- name: Generate experimental catalog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
go run ./cmd/catalog-cd generate-catalog --config ./experimental/externals.yaml experimental
- uses: actions/upload-artifact@v3
with:
name: experimental-catalog-artifact
path: experimental/
retention-days: 3 # We don't need to keep them for long
generate-catalog:
runs-on: ubuntu-latest
if: github.repository_owner == 'openshift-pipelines' # do not run this elsewhere
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/go
- name: Generate catalog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p stable/tasks stable/pipelines
cp -fR tasks/* stable/tasks
cp -fR pipelines/* stable/pipelines
go run ./cmd/catalog-cd generate-catalog --config ./externals.yaml stable
- uses: actions/upload-artifact@v3
with:
name: stable-catalog-artifact
path: stable/
retention-days: 3 # We don't need to keep them for long
publish-experimental-catalog:
runs-on: ubuntu-latest
if: github.repository_owner == 'openshift-pipelines' # do not run this elsewhere
needs:
- generate-experimental-catalog
steps:
- name: Checkout "p" publish branch
uses: actions/checkout@v4
with:
ref: p
- name: Checkout "main" branch
uses: actions/checkout@v4
with:
ref: main
path: main
- name: Sync main "helper code" with p
run: |
# Clean existing
rm -fR automation Makefile .github
# Copy from main
cp -fR main/{automation,Makefile} .
mkdir -p .github/workflows
mkdir -p .github/workflows .github/actions
cp -fR main/.github/workflows/test* .github/workflows
cp -fR main/.github/actions/* .github/actions
- name: Clean old "generated" catalogs
run: |
# Remove experimental resources
rm -fR experimental/{tasks,pipelines}/*
- name: Fetch generated experimental catalog
uses: actions/download-artifact@v3
with:
name: experimental-catalog-artifact
path: experimental
- name: Add experimental catalog to publish branch
run: |
# Clean main from here before the status
rm -fR main
git config user.name github-actions
git config user.email [email protected]
CHANGES=$(git status -s)
if [[ -n "${CHANGES}" ]]; then
git status
git add experimental Makefile automation .github
git commit -m "Auto-update experimental tekton resources"
git pull --rebase --autostash
else
echo "No changes for the experimental catalog"
fi
- name: Create PR
id: create-pr
uses: peter-evans/create-pull-request@v5
with:
base: p
delete-branch: true
add-paths: README.md # This is here just to force it to not commit anything
title: Experimental catalog changes
assignees: tekton-ecosystem-team
labels: approved, lgtm, ok-to-test # Automatically approved :)
# committer: ${{ env.GIT_COMMITTER_NAME }} ${{ env.GIT_COMMITTER_EMAIL }}
# author: ${{ env.GIT_AUTHOR_NAME }} ${{ env.GIT_AUTHOR_EMAIL }}
# body: ${{ steps.pr_body.outputs.content }} # TODO(vdemeester) Write git status from the artifact
publish-catalog:
runs-on: ubuntu-latest
if: github.repository_owner == 'openshift-pipelines' # do not run this elsewhere
needs:
- generate-catalog
steps:
- name: Checkout "p" publish branch
uses: actions/checkout@v4
with:
ref: p
- name: Checkout "main" branch
uses: actions/checkout@v4
with:
ref: main
path: main
- name: Sync main "helper code" with p
run: |
# Clean existing
rm -fR automation Makefile .github
# Copy from main
cp -fR main/{automation,Makefile} .
mkdir -p .github/workflows .github/actions
cp -fR main/.github/workflows/test* .github/workflows
cp -fR main/.github/actions/* .github/actions
- name: Clean old "generated" catalogs
run: |
# Remove "stable" resources
rm -fR {tasks,pipelines}/*
- name: Fetch generated stable catalog
uses: actions/download-artifact@v3
with:
name: stable-catalog-artifact
path: .
- name: Add experimental catalog to publish branch
run: |
# Clean main from here before the status
rm -fR main
git config user.name github-actions
git config user.email [email protected]
CHANGES=$(git status -s)
if [[ -n "${CHANGES}" ]]; then
git status
git add tasks pipelines
git add Makefile automation .github
git commit -m "Auto-update tekton resources"
git pull --rebase --autostash
else
echo "No changes for the catalog"
fi
- name: Create PR
id: create-pr
uses: peter-evans/create-pull-request@v5
with:
base: p
delete-branch: true
add-paths: README.md # This is here just to force it to not commit anything
title: Catalog changes
assignees: tekton-ecosystem-team
labels: approved, lgtm, ok-to-test # Automatically approved :)
# committer: ${{ env.GIT_COMMITTER_NAME }} ${{ env.GIT_COMMITTER_EMAIL }}
# author: ${{ env.GIT_AUTHOR_NAME }} ${{ env.GIT_AUTHOR_EMAIL }}
# body: ${{ steps.pr_body.outputs.content }} # TODO(vdemeester) Write git status from the artifact