Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/chainguard/make-self-upgrade.sts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
# Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/repository-base/base/.github/chainguard/make-self-upgrade.sts.yaml instead.

issuer: https://token.actions.githubusercontent.com
subject_pattern: ^repo:cert-manager/helm-tool:ref:refs/heads/(main|master)$

permissions:
contents: write
pull_requests: write
workflows: write
114 changes: 114 additions & 0 deletions .github/workflows/make-self-upgrade.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
# Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/repository-base/base/.github/workflows/make-self-upgrade.yaml instead.

name: make-self-upgrade
concurrency: make-self-upgrade
on:
workflow_dispatch: {}
schedule:
- cron: '0 0 * * *'

permissions:
contents: read

jobs:
self_upgrade:
runs-on: ubuntu-latest

if: github.repository == 'cert-manager/helm-tool'

permissions:
id-token: write

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

steps:
- 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 non-branch-head."
exit 1

- name: Octo STS Token Exchange
uses: octo-sts/action@e480437973a6f6ac2e9caa40ecabedc870d76395 # v1.0.1
id: octo-sts
with:
scope: 'cert-manager/helm-tool'
identity: make-self-upgrade

- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
# Adding `fetch-depth: 0` makes sure tags are also fetched. We need
# the tags so `git describe` returns a valid version.
# see https://github.com/actions/checkout/issues/701 for extra info about this option
with:
fetch-depth: 0
token: ${{ steps.octo-sts.outputs.token }}

- id: go-version
run: |
make print-go-version >> "$GITHUB_OUTPUT"

- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version: ${{ steps.go-version.outputs.result }}

- run: |
git checkout -B "$SELF_UPGRADE_BRANCH"

- run: |
make -j upgrade-klone
make -j generate

- id: is-up-to-date
shell: bash
run: |
git_status=$(git status -s)
is_up_to_date="true"
if [ -n "$git_status" ]; then
is_up_to_date="false"
echo "The following changes will be committed:"
echo "$git_status"
fi
echo "result=$is_up_to_date" >> "$GITHUB_OUTPUT"

- if: ${{ steps.is-up-to-date.outputs.result != 'true' }}
run: |
git config --global user.name "cert-manager-bot"
git config --global user.email "cert-manager-bot@users.noreply.github.com"
git add -A && git commit -m "BOT: run 'make upgrade-klone' and 'make generate'" --signoff
git push -f origin "$SELF_UPGRADE_BRANCH"

- if: ${{ steps.is-up-to-date.outputs.result != 'true' }}
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
github-token: ${{ steps.octo-sts.outputs.token }}
script: |
const { repo, owner } = context.repo;
const pulls = await github.rest.pulls.list({
owner: owner,
repo: repo,
head: owner + ':' + process.env.SELF_UPGRADE_BRANCH,
base: process.env.SOURCE_BRANCH,
state: 'open',
});

if (pulls.data.length < 1) {
const result = await github.rest.pulls.create({
title: '[CI] Merge ' + process.env.SELF_UPGRADE_BRANCH + ' into ' + process.env.SOURCE_BRANCH,
owner: owner,
repo: repo,
head: process.env.SELF_UPGRADE_BRANCH,
base: process.env.SOURCE_BRANCH,
body: [
'This PR is auto-generated to bump the Makefile modules.',
].join('\n'),
});
await github.rest.issues.addLabels({
owner,
repo,
issue_number: result.data.number,
labels: ['ok-to-test', 'skip-review', 'release-note-none', 'kind/cleanup']
});
}
20 changes: 10 additions & 10 deletions klone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,45 @@ targets:
- folder_name: boilerplate
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: 6fc870c9c2a1bef827834ee66fca9dfce748c518
repo_hash: bbb99406df3c48021577890e2b8f1d9948358bfe
repo_path: modules/boilerplate
- folder_name: cert-manager
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: 6fc870c9c2a1bef827834ee66fca9dfce748c518
repo_hash: bbb99406df3c48021577890e2b8f1d9948358bfe
repo_path: modules/cert-manager
- folder_name: executable
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: 6fc870c9c2a1bef827834ee66fca9dfce748c518
repo_hash: bbb99406df3c48021577890e2b8f1d9948358bfe
repo_path: modules/executable
- folder_name: generate-verify
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: 6fc870c9c2a1bef827834ee66fca9dfce748c518
repo_hash: bbb99406df3c48021577890e2b8f1d9948358bfe
repo_path: modules/generate-verify
- folder_name: go
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: 6fc870c9c2a1bef827834ee66fca9dfce748c518
repo_hash: bbb99406df3c48021577890e2b8f1d9948358bfe
repo_path: modules/go
- folder_name: help
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: 6fc870c9c2a1bef827834ee66fca9dfce748c518
repo_hash: bbb99406df3c48021577890e2b8f1d9948358bfe
repo_path: modules/help
- folder_name: klone
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: 6fc870c9c2a1bef827834ee66fca9dfce748c518
repo_hash: bbb99406df3c48021577890e2b8f1d9948358bfe
repo_path: modules/klone
- folder_name: repository-base
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: renovate-preset
repo_hash: b89fe0aee778669f651fc5cbe667de3fc32a7d44
repo_ref: main
repo_hash: bbb99406df3c48021577890e2b8f1d9948358bfe
repo_path: modules/repository-base
- folder_name: tools
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: 6fc870c9c2a1bef827834ee66fca9dfce748c518
repo_hash: bbb99406df3c48021577890e2b8f1d9948358bfe
repo_path: modules/tools
7 changes: 6 additions & 1 deletion make/_shared/repository-base/01_mod.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ ifndef repo_name
$(error repo_name is not set)
endif

repository_base_dir := $(dir $(lastword $(MAKEFILE_LIST)))/base/
_repository_base_module_dir := $(dir $(lastword $(MAKEFILE_LIST)))
repository_base_dir := $(_repository_base_module_dir)base/

.PHONY: generate-base
## Generate base files in the repository
Expand All @@ -27,5 +28,9 @@ generate-base:
find . -type f | while read file; do \
sed "s|{{REPLACE:GH-REPOSITORY}}|$(repo_name:github.com/%=%)|g" "$$file" > "$(CURDIR)/$$file"; \
done
if [ ! -e ./.github/renovate.json5 ]; then \
mkdir -p ./.github; \
cp $(_repository_base_module_dir)/renovate-bootstrap-config.json5 ./.github/renovate.json5; \
fi

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

issuer: https://token.actions.githubusercontent.com
subject_pattern: ^repo:{{REPLACE:GH-REPOSITORY}}:ref:refs/heads/(main|master)$

permissions:
contents: write
pull_requests: write
workflows: write
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
# Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/repository-base/base/.github/workflows/make-self-upgrade.yaml instead.

name: make-self-upgrade
concurrency: make-self-upgrade
on:
workflow_dispatch: {}
schedule:
- cron: '0 0 * * *'

permissions:
contents: read

jobs:
self_upgrade:
runs-on: ubuntu-latest

if: github.repository == '{{REPLACE:GH-REPOSITORY}}'

permissions:
id-token: write

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

steps:
- 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 non-branch-head."
exit 1

- name: Octo STS Token Exchange
uses: octo-sts/action@e480437973a6f6ac2e9caa40ecabedc870d76395 # v1.0.1
id: octo-sts
with:
scope: '{{REPLACE:GH-REPOSITORY}}'
identity: make-self-upgrade

- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
# Adding `fetch-depth: 0` makes sure tags are also fetched. We need
# the tags so `git describe` returns a valid version.
# see https://github.com/actions/checkout/issues/701 for extra info about this option
with:
fetch-depth: 0
token: ${{ steps.octo-sts.outputs.token }}

- id: go-version
run: |
make print-go-version >> "$GITHUB_OUTPUT"

- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version: ${{ steps.go-version.outputs.result }}

- run: |
git checkout -B "$SELF_UPGRADE_BRANCH"

- run: |
make -j upgrade-klone
make -j generate

- id: is-up-to-date
shell: bash
run: |
git_status=$(git status -s)
is_up_to_date="true"
if [ -n "$git_status" ]; then
is_up_to_date="false"
echo "The following changes will be committed:"
echo "$git_status"
fi
echo "result=$is_up_to_date" >> "$GITHUB_OUTPUT"

- if: ${{ steps.is-up-to-date.outputs.result != 'true' }}
run: |
git config --global user.name "cert-manager-bot"
git config --global user.email "cert-manager-bot@users.noreply.github.com"
git add -A && git commit -m "BOT: run 'make upgrade-klone' and 'make generate'" --signoff
git push -f origin "$SELF_UPGRADE_BRANCH"

- if: ${{ steps.is-up-to-date.outputs.result != 'true' }}
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
github-token: ${{ steps.octo-sts.outputs.token }}
script: |
const { repo, owner } = context.repo;
const pulls = await github.rest.pulls.list({
owner: owner,
repo: repo,
head: owner + ':' + process.env.SELF_UPGRADE_BRANCH,
base: process.env.SOURCE_BRANCH,
state: 'open',
});

if (pulls.data.length < 1) {
const result = await github.rest.pulls.create({
title: '[CI] Merge ' + process.env.SELF_UPGRADE_BRANCH + ' into ' + process.env.SOURCE_BRANCH,
owner: owner,
repo: repo,
head: process.env.SELF_UPGRADE_BRANCH,
base: process.env.SOURCE_BRANCH,
body: [
'This PR is auto-generated to bump the Makefile modules.',
].join('\n'),
});
await github.rest.issues.addLabels({
owner,
repo,
issue_number: result.data.number,
labels: ['ok-to-test', 'skip-review', 'release-note-none', 'kind/cleanup']
});
}
6 changes: 6 additions & 0 deletions make/_shared/repository-base/renovate-bootstrap-config.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
$schema: 'https://docs.renovatebot.com/renovate-schema.json',
extends: [
'github>cert-manager/renovate-config:default.json5',
],
}
Loading