forked from tektoncd/chains
-
Notifications
You must be signed in to change notification settings - Fork 1
94 lines (76 loc) · 2.91 KB
/
update-sources.main.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
# Generated by openshift-pipelines/hack. DO NOT EDIT.
name: update-sources-main
on:
workflow_dispatch: {}
schedule:
- cron: "30 */12 * * *" # At minute 30 past every 12th hour.
jobs:
update-sources:
runs-on: ubuntu-latest
if: github.repository_owner == 'openshift-pipelines' # do not run this elsewhere
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout the current repo
uses: actions/checkout@v4
with:
ref: main
- name: Clone tektoncd/chains
run: |
rm -fR upstream
git clone https://github.com/tektoncd/chains upstream
pushd upstream
git checkout -B main origin/main
popd
- name: Generate patches
run: |
pushd upstream
sed -i "s%go 1.22.*%go 1.22%g" go.mod
sed -i "s%go 1.22.*%go 1.22%g" vendor/modules.txt
git diff > ../.konflux/patches/0000-go1.22.patch
# clean after yourself >:D
git checkout HEAD go.mod vendor/modules.txt
sed -i "s%go 1.23.*%go 1.22%g" go.mod
sed -i "s%go 1.23.*%go 1.22%g" vendor/modules.txt
git diff > ../.konflux/patches/0000-go1.23.patch
# clean after yourself >:D
git checkout HEAD go.mod vendor/modules.txt
popd
- name: Commit new changes
run: |
git config user.name openshift-pipelines-bot
git config user.email [email protected]
git checkout -b actions/update/sources-main
pushd upstream
OLD_COMMIT=$(cat ../head)
NEW_COMMIT=$(git rev-parse HEAD)
echo Previous commit: ${OLD_COMMIT}
git show --stat ${OLD_COMMIT}
echo New commit: ${NEW_COMMIT}
git show --stat ${NEW_COMMIT}
git diff --stat ${NEW_COMMIT}..${OLD_COMMIT} > /tmp/diff.txt
git rev-parse HEAD > ../head
popd
rm -rf upstream/.git
git add upstream head .konflux
if [[ -z $(git status --porcelain --untracked-files=no) ]]; then
echo "No change, exiting"
exit 0
fi
git commit -F- <<EOF
[bot] Update main from tektoncd/chains to ${NEW_COMMIT}
$ git diff --stat ${NEW_COMMIT}..${OLD_COMMIT}
$(cat /tmp/diff.txt | sed 's/^/ /')
https://github.com/tektoncd/chains/compare/${NEW_COMMIT}..${OLD_COMMIT}
EOF
git push -f origin actions/update/sources-main
if [ "$(gh pr list --base main --head actions/update/sources-main --json url --jq 'length')" = "0" ]; then
echo "creating PR..."
gh pr create -B main -H actions/update/sources-main --label=automated --label=upstream --fill
else
echo "a PR already exists, editing..."
gh pr edit --title "[bot] Update main from tektoncd/chains to ${NEW_COMMIT}" --body "$(cat /tmp/diff.txt | sed 's/^/ /')"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}