-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: Bump image version in the Harvester repo when tagging #174
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# branch mapping from this repo to harvester | ||
mappings: | ||
v0.5.x: v1.2 | ||
v0.6.x: v1.3 | ||
v0.7.x: v1.4 | ||
v0.8.x: v1.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: Create PR to bump image tags in the Harvester repo | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
component: | ||
description: 'The component to bump images' | ||
required: true | ||
type: string | ||
version: | ||
description: 'The version of the image to bump' | ||
required: true | ||
type: string | ||
harvester_repo: | ||
description: 'The repository to bump the image in' | ||
default: 'harvester/harvester' | ||
required: false | ||
type: string | ||
|
||
jobs: | ||
create: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Dump GitHub context | ||
env: | ||
GITHUB_CONTEXT: ${{ toJson(github) }} | ||
run: echo "$GITHUB_CONTEXT" | ||
- uses: actions/checkout@v4 | ||
with: | ||
path: ${{ github.event.repository.name }} | ||
# checkout the default branch to get the branch mappings, so we don't need to update | ||
# every supported branch. | ||
ref: ${{ github.event.repository.default_branch }} | ||
- name: Get corresponding harvester branch | ||
id: detect | ||
run: | | ||
version="${{ inputs.version }}" | ||
echo "version: $version" | ||
|
||
cd ${{ github.event.repository.name }} | ||
|
||
# Find the branch name from a tag name in the current repo: v7.7.7 -> v7.7.x | ||
# And find the corresponding branch name in the harvester repo: v7.7.x -> v1.4 | ||
repo_branch="$(echo "$version" | sed -E 's/(v[0-9]+\.[0-9]+)\.[0-9]+/\1.x/g')" | ||
echo "repo_branch: $repo_branch" | ||
harvester_branch="$(branch="$repo_branch" yq ".mappings.[env(branch)] // \"\"" .github/branch-mappings.yaml)" | ||
if [ -z "$harvester_branch" ]; then | ||
echo "[ERROR] No corresponding Harvester branch found for version $version, branch $repo_branch" | ||
echo "[ERROR] Check the branch mappings in .github/branch-mappings.yaml" | ||
exit 1 | ||
fi | ||
|
||
echo "::notice title=Branch Mapping::repo_branch: $repo_branch, harvester_branch=$harvester_branch" | ||
echo "harvester_branch=$harvester_branch" >> "$GITHUB_OUTPUT" | ||
|
||
- name: Clone harvester/harvester repo | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ inputs.harvester_repo }} | ||
ref: ${{ steps.detect.outputs.harvester_branch }} | ||
path: harvester | ||
- name: Update image tags in the values file | ||
run: | | ||
set -x | ||
|
||
cd harvester | ||
# Search for a component and replace all the "tag: xxx" occurrences in the section | ||
# We first search the component name as the start line | ||
# And find the next component name as the end line | ||
sed -i '/${{ inputs.component }}:/,/^[^ #].*:$/s/tag:\s.*/tag: ${{ inputs.version }}/' deploy/charts/harvester/values.yaml | ||
git --no-pager diff --no-color | ||
- name: Create harvester PR | ||
uses: peter-evans/create-pull-request@v7 | ||
with: | ||
path: harvester | ||
token: ${{ secrets.HARVESTER_BOT_TOKEN }} | ||
commit-message: Bump ${{ inputs.component }} to ${{ inputs.version }} | ||
committer: GitHub <[email protected]> | ||
author: Harvester Bot <[email protected]> | ||
signoff: false | ||
branch: bump-${{ inputs.component }}-${{ inputs.version }} | ||
delete-branch: false | ||
title: Bump ${{ inputs.component }} to ${{ inputs.version }} | ||
draft: false | ||
body: | | ||
Bump ${{ inputs.component }} to ${{ inputs.version }}. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good.
Can we have this for all independently released components?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm struggling with this. To centralize in one place or controlled in each repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add an action in the harvester repo to regularly scan these component repos, check for any new tags or releases, and update the related tags accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initial idea is repo-based. The intention is just to make the owner's life easier.
I'll close this one and see what I can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about the submodule to handle the whole components update?
If we centralize this thing, maybe we could use other ways, not just bash-based GHA.
Could we do it easier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason to keep this inside a repo is the workflow can be run after images are successfully published. Or even run after some tests (if there are any) defined by the repo.
Using a separate job to scan all component repos will be more complicated, we'll need to check if CI is running well when the tag was happening.
How about creating an action, and every repo just needs to use the action?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am ok with that.
Just one thing I would like to confirm again. Suppose we use the centralized GitHub action. That means we need to use the same branch naming, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, a branch_mapping mapping file should be kept in the individual repo (just like this PR). I prefer this rather than keeping it in a centralized place. The advantage is the repo owner can know and update the mapping when working on the repo, no need to jump to the centralized repo. The drawback is we don't have a place to know all the mappings for all projects in one place.