Added github workflow to automatic update noobaa-core image tag#1642
Added github workflow to automatic update noobaa-core image tag#1642aayushchouhan09 merged 1 commit intonoobaa:masterfrom
Conversation
WalkthroughA new GitHub Actions workflow is added to automate updating the Noobaa-Core container image tag in the codebase. The workflow creates a pull request with the updated tag, waits for checks to pass, and merges the change automatically. It is manually triggered and requires the new tag as input. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant GitHub Actions
participant Repo
User->>GitHub Actions: Trigger workflow with container_image_tag
GitHub Actions->>Repo: Checkout master branch
GitHub Actions->>Repo: Update ContainerImageTag in options.go
GitHub Actions->>Repo: Commit and push new branch
GitHub Actions->>Repo: Create pull request to master
GitHub Actions->>GitHub Actions: Wait for PR checks
GitHub Actions->>Repo: Merge PR and delete branch (if checks succeed)
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
.github/workflows/update-noobaa-core-tag.yaml (4)
31-39: Handle “no-change” & pre-existing branch scenarios
git checkout -bfails if the branch already exists, andgit commiterrors when there is nothing to commit (e.g., tag unchanged).
A more robust snippet:- git checkout -b update-core-tag-${{ github.event.inputs.container_image_tag }} + git checkout -B update-core-tag-${{ github.event.inputs.container_image_tag }} - git diff - git add pkg/options/options.go - git commit -m "chore: update noobaa-core image tag to ${{ github.event.inputs.container_image_tag }}" + if ! git diff --quiet; then + git add pkg/options/options.go + git commit -m "chore: update noobaa-core image tag to ${{ github.event.inputs.container_image_tag }}" + else + echo "No changes detected – skipping commit." + exit 0 + fi
41-49:ghauthentication can be skipped – reuse the existing token
actions/checkoutalready set up the remote with the PAT, andghautomatically picks upGITHUB_TOKEN.
You can drop the interactive login and rely on env-var auth:- gh auth login --with-token <<< "${{ secrets.GHACTION_TOKEN_WRITE }}"If you keep the login step, add
set -euo pipefailat the top of the script to fail fast on auth issues.
26-30: Minor formatting issues flagged by yamllintTrailing spaces and an extra blank line break linting rules.
-26␠ -30␠ -53␠ -Clean these up to keep the workflow lint-clean.
Also applies to: 53-54
51-51: Automate the “wait for tests & merge” TODOConsider the
peter-evans/wait-for-checkandpeter-evans/enable-pull-request-automergeactions to automatically merge once CI succeeds.
Happy to draft a follow-up patch if needed.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/update-noobaa-core-tag.yaml(1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/update-noobaa-core-tag.yaml
[error] 26-26: trailing spaces
(trailing-spaces)
[error] 30-30: trailing spaces
(trailing-spaces)
[error] 53-53: trailing spaces
(trailing-spaces)
[warning] 54-54: too many blank lines
(1 > 0) (empty-lines)
⏰ Context from checks skipped due to timeout of 90000ms (13)
- GitHub Check: run-azure-vault-test
- GitHub Check: run-cli-tests
- GitHub Check: run-operator-tests
- GitHub Check: run-kms-kmip-test
- GitHub Check: run-kms-tls-sa-test
- GitHub Check: run-kms-key-rotate-test
- GitHub Check: run-hac-test
- GitHub Check: golangci-lint
- GitHub Check: cnpg-deployment-test
- GitHub Check: run-core-config-map-tests
- GitHub Check: run-kms-tls-token-test
- GitHub Check: run-kms-dev-test
- GitHub Check: run-admission-test
🔇 Additional comments (1)
.github/workflows/update-noobaa-core-tag.yaml (1)
22-26: Ignore explicittokenfor checkout
The workflow’s job-levelenvalready setsGITHUB_TOKEN: ${{ secrets.GHACTION_TOKEN_WRITE }}, andactions/checkout@v4will default to usingprocess.env.GITHUB_TOKEN. No additionaltokeninput is required.• File:
.github/workflows/update-noobaa-core-tag.yaml
– Lines 18–19 define
yaml env: GITHUB_TOKEN: ${{ secrets.GHACTION_TOKEN_WRITE }}
• Checkout step (lines 22–26) will inherit that token automatically.Likely an incorrect or invalid review comment.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
.github/workflows/update-noobaa-core-tag.yaml (2)
26-26: Trim trailing whitespace to satisfy YAMLlintThe workflow currently violates the repository’s YAML lint rules (see static-analysis hints) because of trailing spaces on otherwise blank lines. While harmless to GitHub Actions, letting these accumulate adds noise to future diffs and breaks pre-commit hooks.
- +Also applies to: 32-32, 55-55
56-63: Bound the wait loop to avoid hanging runs
gh pr checks … --watchwaits indefinitely; if a check stalls the job will hit the 90-minute job timeout. Pass an explicit timeout/interval (supported since gh 2.50) or poll with a capped loop so the workflow fails fast and surfaces the underlying issue.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/update-noobaa-core-tag.yaml(1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/update-noobaa-core-tag.yaml
[error] 26-26: trailing spaces
(trailing-spaces)
[error] 32-32: trailing spaces
(trailing-spaces)
[error] 55-55: trailing spaces
(trailing-spaces)
⏰ Context from checks skipped due to timeout of 90000ms (12)
- GitHub Check: run-kms-tls-sa-test
- GitHub Check: run-hac-test
- GitHub Check: run-azure-vault-test
- GitHub Check: run-operator-tests
- GitHub Check: run-kms-key-rotate-test
- GitHub Check: run-kms-tls-token-test
- GitHub Check: run-cli-tests
- GitHub Check: cnpg-deployment-test
- GitHub Check: run-kms-dev-test
- GitHub Check: run-kms-kmip-test
- GitHub Check: run-admission-test
- GitHub Check: run-core-config-map-tests
🔇 Additional comments (1)
.github/workflows/update-noobaa-core-tag.yaml (1)
37-41: Sanitise branch names derived from user input
git checkout -b update-core-tag-${{ github.event.inputs.container_image_tag }}assumes the tag is a valid ref. Tags often contain/,:, or uppercase characters, all illegal or awkward in branch names and will cause the step to fail.Consider:
branch_safe=$(echo "$tag" | tr '/:' '__' | tr '[:upper:]' '[:lower:]') git checkout -b "update-core-tag-${branch_safe}"
| runs-on: ubuntu-latest | ||
| timeout-minutes: 90 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GHACTION_TOKEN_WRITE }} |
There was a problem hiding this comment.
Is there a reason to use GHACTION_TOKEN_WRITE over GITHUB_TOKEN?
There was a problem hiding this comment.
We need to merge the PR in this action, not sure if GHACTION_TOKEN_WRITE has such access.
@tangledbytes Can you pls confirm if it is possible to merge the PR with this token.
There was a problem hiding this comment.
Honestly, I am not sure. But from the documentation it seems that GITHUB_TOKEN when given permissions.pull-requests = true does grant access to the /merge endpoint. Let's try just with GITHUB_TOKEN and let's see if that works, if not we can fix it in a subsequent PR, WDYT?
There was a problem hiding this comment.
Sure Thanks, I will try that
There was a problem hiding this comment.
@tangledbytes I have tested it we need a token with below permissions:
- repo (Full control of private repositories)
- workflow (Update GitHub Action workflows)
- read:org (Read org and team membership, read org projects)
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
.github/workflows/update-noobaa-core-tag.yaml (4)
18-20: Prefersecrets.GITHUB_TOKENover a custom PAT unless additional scopes are requiredOverriding
GITHUB_TOKENwithsecrets.GHACTION_TOKEN_WRITEadds another secret to manage and audit.
The built-inGITHUB_TOKENalready hascontents: writeandpull-requests: writescopes (as configured underpermissions:) and works with both theghCLI and most third-party actions.- env: - GITHUB_TOKEN: ${{ secrets.GHACTION_TOKEN_WRITE }} + env: + # Use GitHub-provided token; it inherits the permissions block above + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39-44: Guard against branch-name collisions on repeated runsIf the same tag is processed twice (or the first run fails after the push), subsequent pushes will error because the branch already exists.
- git checkout -b update-core-tag-${{ github.event.inputs.container_image_tag }} + ts=$(date +%s) + git checkout -b update-core-tag-${{ github.event.inputs.container_image_tag }}-$tsAlternatively add
--force-with-leaseongit push.
Without this, the workflow will exit early and the tag won’t be updated.
1-17: Consider adding a concurrency group to prevent simultaneous runsIf two operators trigger the workflow at the same time, concurrent jobs can stomp on each other’s branches and PRs.
concurrency: group: noobaa-core-tag-update cancel-in-progress: true
24-34: Strip trailing whitespace to appease YAMLlintThe linter flags lines 26, 34 and 57 for trailing spaces. Cleaning them avoids noisy CI failures.
- ref: master␠ + ref: master ... - regex: true␠ + regex: true ... -␠ +Also applies to: 55-59
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/update-noobaa-core-tag.yaml(1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/update-noobaa-core-tag.yaml
[error] 26-26: trailing spaces
(trailing-spaces)
[error] 34-34: trailing spaces
(trailing-spaces)
[error] 57-57: trailing spaces
(trailing-spaces)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
- GitHub Check: run-operator-tests
- GitHub Check: cnpg-deployment-test
- GitHub Check: run-hac-test
- GitHub Check: run-kms-kmip-test
- GitHub Check: run-kms-key-rotate-test
- GitHub Check: run-kms-dev-test
- GitHub Check: run-cli-tests
- GitHub Check: run-core-config-map-tests
- GitHub Check: golangci-lint
- GitHub Check: run-admission-test
- GitHub Check: run-azure-vault-test
- GitHub Check: run-kms-tls-token-test
- GitHub Check: run-kms-tls-sa-test
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
.github/workflows/update-noobaa-core-tag.yml (4)
24-26: Remove trailing whitespace to pass YAML lintYAMLlint is currently failing on this line because of a stray space after
master.
Clean-up avoids noisy CI failures.- ref: master␠ + ref: master
31-34: Trim trailing whitespace in thewith:blockMore trailing spaces (after
pkg/options/options.go). These will keep triggering YAML-lint.- include: 'pkg/options/options.go'␠ + include: 'pkg/options/options.go' - regex: true␠ + regex: true
54-57: Delete the blank line that contains spacesLine 56 is an otherwise-empty line that still carries whitespace.
Kill it to stay lint-clean.- +
14-17: Add a concurrency key to prevent overlapping runsParallel manual triggers with different tags could race to update the same file/branch.
Using a concurrency group guarantees one tag update at a time.update-tag: + concurrency: + group: core-tag-update + cancel-in-progress: false runs-on: ubuntu-latest
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/update-noobaa-core-tag.yml(1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/update-noobaa-core-tag.yml
[error] 26-26: trailing spaces
(trailing-spaces)
[error] 34-34: trailing spaces
(trailing-spaces)
[error] 56-56: trailing spaces
(trailing-spaces)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
- GitHub Check: run-cli-tests
- GitHub Check: run-kms-tls-token-test
- GitHub Check: run-operator-tests
- GitHub Check: run-core-config-map-tests
- GitHub Check: run-admission-test
- GitHub Check: cnpg-deployment-test
- GitHub Check: run-kms-dev-test
- GitHub Check: run-azure-vault-test
- GitHub Check: run-kms-tls-sa-test
- GitHub Check: run-kms-key-rotate-test
- GitHub Check: run-hac-test
- GitHub Check: run-kms-kmip-test
|
@achouhan09, What is the purpose of this PR? I may be missing some context. |
|
@dannyzaken yes you are correct. |
Neon-White
left a comment
There was a problem hiding this comment.
Some suggestions, almost good to go
8b30960 to
22421e3
Compare
Signed-off-by: Aayush <aayush@li-2392f9cc-287a-11b2-a85c-9fcc04b05da6.ibm.com>
92dc987 to
b556750
Compare
Explain the changes
Issues: Fixed #xxx
GAPS:
container_image_tagas the input, once everything works fine we will automate the image tag as well.GITHUB_TOKENwith the access for PRs write.Testing Instructions:
Summary by CodeRabbit