Skip to content

Commit

Permalink
Merge pull request #238 from inteon/upgrade_repository-base
Browse files Browse the repository at this point in the history
Upgrade repository-base module
  • Loading branch information
inteon authored Apr 22, 2024
2 parents a2642a1 + f0ee4f2 commit a58f3b3
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 33 deletions.
6 changes: 3 additions & 3 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
# Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/repository-base/base/.github/dependabot.yaml instead.

# Update Go dependencies and GitHub Actions dependencies weekly.
# Update Go dependencies and GitHub Actions dependencies daily.
version: 2
updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly
interval: daily
groups:
all:
patterns: ["*"]
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
interval: daily
groups:
all:
patterns: ["*"]
30 changes: 17 additions & 13 deletions .github/workflows/make-self-upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@ on:
- cron: '0 0 * * *'

jobs:
build_images:
self_upgrade:
runs-on: ubuntu-latest

permissions:
contents: write
pull-requests: write

env:
SOURCE_BRANCH: "${{ github.ref_name }}"
SELF_UPGRADE_BRANCH: "self-upgrade-${{ github.ref_name }}"

steps:
- name: Fail if branch is not main
if: github.ref != 'refs/heads/main'
- name: Fail if branch is not head of branch.
if: ${{ !startsWith(github.ref, 'refs/heads/') && env.SOURCE_BRANCH != '' && env.SELF_UPGRADE_BRANCH != '' }}
run: |
echo "This workflow should not be run on a branch other than main."
echo "This workflow should not be run on a non-branch-head."
exit 1
- uses: actions/checkout@v4
Expand All @@ -34,7 +38,7 @@ jobs:
go-version: ${{ steps.go-version.outputs.result }}

- run: |
git checkout -B "self-upgrade"
git checkout -B "$SELF_UPGRADE_BRANCH"
- run: |
make -j upgrade-klone
Expand All @@ -54,10 +58,10 @@ jobs:
- if: ${{ steps.is-up-to-date.outputs.result != 'true' }}
run: |
git config --global user.name "jetstack-bot"
git config --global user.email "jetstack[email protected]"
git config --global user.name "cert-manager-bot"
git config --global user.email "cert-manager[email protected]"
git add -A && git commit -m "BOT: run 'make upgrade-klone' and 'make generate'" --signoff
git push -f origin self-upgrade
git push -f origin "$SELF_UPGRADE_BRANCH"
- if: ${{ steps.is-up-to-date.outputs.result != 'true' }}
uses: actions/github-script@v7
Expand All @@ -67,18 +71,18 @@ jobs:
const pulls = await github.rest.pulls.list({
owner: owner,
repo: repo,
head: owner + ':self-upgrade',
base: 'main',
head: owner + ':' + process.env.SELF_UPGRADE_BRANCH,
base: process.env.SOURCE_BRANCH,
state: 'open',
});
if (pulls.data.length < 1) {
await github.rest.pulls.create({
title: '[CI] Merge self-upgrade into main',
title: '[CI] Merge ' + process.env.SELF_UPGRADE_BRANCH + ' into ' + process.env.SOURCE_BRANCH,
owner: owner,
repo: repo,
head: 'self-upgrade',
base: 'main',
head: process.env.SELF_UPGRADE_BRANCH,
base: process.env.SOURCE_BRANCH,
body: [
'This PR is auto-generated to bump the Makefile modules.',
].join('\n'),
Expand Down
2 changes: 1 addition & 1 deletion klone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ targets:
- folder_name: repository-base
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: fa9c9274d1d852de501461b9442f7206aaf74007
repo_hash: e9363accaaee20a995bbf8f1c9cba2ea77da8935
repo_path: modules/repository-base
- folder_name: tools
repo_url: https://github.com/cert-manager/makefile-modules.git
Expand Down
10 changes: 10 additions & 0 deletions make/_shared/repository-base/01_mod.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,21 @@
# limitations under the License.

base_dir := $(dir $(lastword $(MAKEFILE_LIST)))/base/
base_dependabot_dir := $(dir $(lastword $(MAKEFILE_LIST)))/base-dependabot/

ifdef repository_base_no_dependabot
.PHONY: generate-base
## Generate base files in the repository
## @category [shared] Generate/ Verify
generate-base:
cp -r $(base_dir)/. ./
else
.PHONY: generate-base
## Generate base files in the repository
## @category [shared] Generate/ Verify
generate-base:
cp -r $(base_dir)/. ./
cp -r $(base_dependabot_dir)/. ./
endif

shared_generate_targets += generate-base
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
# Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/repository-base/base/.github/dependabot.yaml instead.

# Update Go dependencies and GitHub Actions dependencies weekly.
# Update Go dependencies and GitHub Actions dependencies daily.
version: 2
updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly
interval: daily
groups:
all:
patterns: ["*"]
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
interval: daily
groups:
all:
patterns: ["*"]
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@ on:
- cron: '0 0 * * *'

jobs:
build_images:
self_upgrade:
runs-on: ubuntu-latest

permissions:
contents: write
pull-requests: write

env:
SOURCE_BRANCH: "${{ github.ref_name }}"
SELF_UPGRADE_BRANCH: "self-upgrade-${{ github.ref_name }}"

steps:
- name: Fail if branch is not main
if: github.ref != 'refs/heads/main'
- name: Fail if branch is not head of branch.
if: ${{ !startsWith(github.ref, 'refs/heads/') && env.SOURCE_BRANCH != '' && env.SELF_UPGRADE_BRANCH != '' }}
run: |
echo "This workflow should not be run on a branch other than main."
echo "This workflow should not be run on a non-branch-head."
exit 1
- uses: actions/checkout@v4
Expand All @@ -34,7 +38,7 @@ jobs:
go-version: ${{ steps.go-version.outputs.result }}

- run: |
git checkout -B "self-upgrade"
git checkout -B "$SELF_UPGRADE_BRANCH"
- run: |
make -j upgrade-klone
Expand All @@ -54,10 +58,10 @@ jobs:
- if: ${{ steps.is-up-to-date.outputs.result != 'true' }}
run: |
git config --global user.name "jetstack-bot"
git config --global user.email "jetstack[email protected]"
git config --global user.name "cert-manager-bot"
git config --global user.email "cert-manager[email protected]"
git add -A && git commit -m "BOT: run 'make upgrade-klone' and 'make generate'" --signoff
git push -f origin self-upgrade
git push -f origin "$SELF_UPGRADE_BRANCH"
- if: ${{ steps.is-up-to-date.outputs.result != 'true' }}
uses: actions/github-script@v7
Expand All @@ -67,18 +71,18 @@ jobs:
const pulls = await github.rest.pulls.list({
owner: owner,
repo: repo,
head: owner + ':self-upgrade',
base: 'main',
head: owner + ':' + process.env.SELF_UPGRADE_BRANCH,
base: process.env.SOURCE_BRANCH,
state: 'open',
});
if (pulls.data.length < 1) {
await github.rest.pulls.create({
title: '[CI] Merge self-upgrade into main',
title: '[CI] Merge ' + process.env.SELF_UPGRADE_BRANCH + ' into ' + process.env.SOURCE_BRANCH,
owner: owner,
repo: repo,
head: 'self-upgrade',
base: 'main',
head: process.env.SELF_UPGRADE_BRANCH,
base: process.env.SOURCE_BRANCH,
body: [
'This PR is auto-generated to bump the Makefile modules.',
].join('\n'),
Expand Down

0 comments on commit a58f3b3

Please sign in to comment.