-
Notifications
You must be signed in to change notification settings - Fork 3
97 lines (89 loc) · 2.99 KB
/
generate-konflux.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
---
name: Generate konflux configurations
on:
push:
branches:
- 'main'
schedule:
- cron: "0 6 * * *" # Daily at 06:00.
workflow_dispatch: # Manual workflow trigger
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-matrix:
runs-on: ubuntu-latest
if: github.repository_owner == 'openshift-pipelines' # do not run this elsewhere
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22.x
- id: set-matrix
run: |
echo "projects=$(go run ./cmd/matrix config/konflux/*)" >> $GITHUB_OUTPUT
outputs:
projects: ${{ steps.set-matrix.outputs.projects }}
update-project:
needs: build-matrix
if: github.repository_owner == 'openshift-pipelines' # do not run this elsewhere
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project: ${{ fromJSON(needs.build-matrix.outputs.projects) }}
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Clone ${{matrix.project}}
uses: actions/checkout@v4
with:
repository: openshift-pipelines/${{matrix.project}}
path: project
- name: Synchronize labels
run: |
pushd project
gh label clone openshift-pipelines/hack
popd
env:
GH_TOKEN: ${{ secrets.OPENSHIFT_PIPELINES_ROBOT }}
GITHUB_TOKEN: ${{ secrets.OPENSHIFT_PIPELINES_ROBOT }}
- uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Generate configurations
run: |
go run ./cmd/konflux/ -target project -config config/konflux/${{matrix.project}}.yaml
pushd project
git status
popd
- name: Commit new changes
run: |
pushd project
git config user.name openshift-pipelines-bot
git config user.email [email protected]
git checkout -b actions/update/konflux-configuration
git add .github .konflux .tekton
if [[ -z $(git status --porcelain --untracked-files=no) ]]; then
echo "No change, exiting"
exit 0
fi
git commit -m "[bot] update konflux configuration"
# unset extraheader...
git config -l | grep 'http\..*\.extraheader' | cut -d= -f1 | xargs -L1 git config --unset-all
gh auth status
gh auth setup-git
git push -f origin actions/update/konflux-configuration
if [ "$(gh pr list --base main --head actions/update/konflux-configuration --json url --jq 'length')" = "0" ]; then
echo "creating PR..."
gh pr create -B main -H actions/update/konflux-configuration --label=hack --label=automated --fill
else
echo "a PR already exists, skipping..."
fi
env:
GH_TOKEN: ${{ secrets.OPENSHIFT_PIPELINES_ROBOT }}
GITHUB_TOKEN: ${{ secrets.OPENSHIFT_PIPELINES_ROBOT }}