...
1# THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
2# Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/repository-base/base/.github/workflows/make-self-upgrade.yaml instead.
3
4name: make-self-upgrade
5concurrency: make-self-upgrade
6on:
7 workflow_dispatch: {}
8 schedule:
9 - cron: '0 0 * * *'
10
11jobs:
12 self_upgrade:
13 runs-on: ubuntu-latest
14
15 permissions:
16 contents: write
17 pull-requests: write
18
19 env:
20 SOURCE_BRANCH: "${{ github.ref_name }}"
21 SELF_UPGRADE_BRANCH: "self-upgrade-${{ github.ref_name }}"
22
23 steps:
24 - name: Fail if branch is not head of branch.
25 if: ${{ !startsWith(github.ref, 'refs/heads/') && env.SOURCE_BRANCH != '' && env.SELF_UPGRADE_BRANCH != '' }}
26 run: |
27 echo "This workflow should not be run on a non-branch-head."
28 exit 1
29
30 - uses: actions/checkout@v4
31
32 - id: go-version
33 run: |
34 make print-go-version >> "$GITHUB_OUTPUT"
35
36 - uses: actions/setup-go@v5
37 with:
38 go-version: ${{ steps.go-version.outputs.result }}
39
40 - run: |
41 git checkout -B "$SELF_UPGRADE_BRANCH"
42
43 - run: |
44 make -j upgrade-klone
45 make -j generate
46
47 - id: is-up-to-date
48 shell: bash
49 run: |
50 git_status=$(git status -s)
51 is_up_to_date="true"
52 if [ -n "$git_status" ]; then
53 is_up_to_date="false"
54 echo "The following changes will be committed:"
55 echo "$git_status"
56 fi
57 echo "result=$is_up_to_date" >> "$GITHUB_OUTPUT"
58
59 - if: ${{ steps.is-up-to-date.outputs.result != 'true' }}
60 run: |
61 git config --global user.name "cert-manager-bot"
62 git config --global user.email "cert-manager-bot@users.noreply.github.com"
63 git add -A && git commit -m "BOT: run 'make upgrade-klone' and 'make generate'" --signoff
64 git push -f origin "$SELF_UPGRADE_BRANCH"
65
66 - if: ${{ steps.is-up-to-date.outputs.result != 'true' }}
67 uses: actions/github-script@v7
68 with:
69 script: |
70 const { repo, owner } = context.repo;
71 const pulls = await github.rest.pulls.list({
72 owner: owner,
73 repo: repo,
74 head: owner + ':' + process.env.SELF_UPGRADE_BRANCH,
75 base: process.env.SOURCE_BRANCH,
76 state: 'open',
77 });
78
79 if (pulls.data.length < 1) {
80 await github.rest.pulls.create({
81 title: '[CI] Merge ' + process.env.SELF_UPGRADE_BRANCH + ' into ' + process.env.SOURCE_BRANCH,
82 owner: owner,
83 repo: repo,
84 head: process.env.SELF_UPGRADE_BRANCH,
85 base: process.env.SOURCE_BRANCH,
86 body: [
87 'This PR is auto-generated to bump the Makefile modules.',
88 ].join('\n'),
89 });
90 }
View as plain text