Skip to content

Conversation

tolbrino
Copy link
Contributor

Ported from https://github.com/hoprnet/hoprnet/pull/7255/files#diff-97e1e79b4ecbd5261fd1b1a49312400b613bd1953d84d3485019f8eb0667d2e6

Can be merged since the change will only be picked up after merge.

@tolbrino tolbrino added this to the 3.0.0 milestone Jul 14, 2025
@tolbrino tolbrino requested a review from ausias-armesto July 14, 2025 11:50
@tolbrino tolbrino self-assigned this Jul 14, 2025
@Copilot Copilot AI review requested due to automatic review settings July 14, 2025 11:50
Copy link
Contributor

coderabbitai bot commented Jul 14, 2025

📝 Walkthrough

Walkthrough

The workflow for deploying via GitHub Actions was updated to change the trigger conditions, now requiring stricter checks on the package input, continuous deployment flag, and PR labels. Additionally, the authentication token for the repository dispatch action was switched from the default GitHub token to a custom runner token.

Changes

Files Change Summary
.github/workflows/build-docker.yaml Updated deploy trigger conditions and replaced GITHUB_TOKEN with GH_RUNNER_TOKEN for dispatch action

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant GitHub Actions
    participant Repository

    Developer->>GitHub Actions: Push/PR with package='hoprd', CD enabled, label='deploy_nodes'
    GitHub Actions->>GitHub Actions: Evaluate new trigger conditions
    alt All conditions met
        GitHub Actions->>Repository: repository_dispatch (using GH_RUNNER_TOKEN)
    end
Loading

Possibly related PRs

Suggested labels

devops

Suggested reviewers

  • Teebor-Choka

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@tolbrino tolbrino enabled auto-merge (squash) July 14, 2025 11:51
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Ports the deploy_nodes trigger logic from the upstream repository into our CI workflow and updates the token used for repository dispatch.

  • Simplifies the if condition to use the pr-labels step output instead of env.GITHUB_PR_LABEL_DEPLOY_NODES or inputs.production
  • Swaps GITHUB_TOKEN for GH_RUNNER_TOKEN when calling peter-evans/repository-dispatch
Comments suppressed due to low confidence (3)

.github/workflows/build-docker.yaml:148

  • Ensure that the step with ID pr-labels is defined earlier in this workflow and actually outputs a labels array; otherwise this condition will always evaluate to false.
        if: inputs.package == 'hoprd' && vars.CONTINUOUS_DEPLOYMENT_ENABLED == 'true' && contains(steps.pr-labels.outputs.labels, 'deploy_nodes')

.github/workflows/build-docker.yaml:151

  • Add a comment or update the repo documentation to note that GH_RUNNER_TOKEN must be set in GitHub Secrets with the necessary scopes to dispatch workflows.
          token: ${{ secrets.GH_RUNNER_TOKEN }}

.github/workflows/build-docker.yaml:147

  • [nitpick] Double-check the removal of the inputs.production check; if you still need to trigger deploys for production packages without a PR label, consider reintroducing or documenting this change.
      - name: Trigger deploy workflow if needed

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 943af8f and 8f3708d.

📒 Files selected for processing (1)
  • .github/workflows/build-docker.yaml (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: NumberFour8
PR: hoprnet/hoprnet#6630
File: crypto/packet/src/por.rs:84-84
Timestamp: 2024-11-13T17:56:37.536Z
Learning: In PR #6630, the changes include the removal of ticket validation from the last hop and fixes for Index Offset handling as specified in the PR objectives.
Learnt from: Teebor-Choka
PR: hoprnet/hoprnet#6545
File: transport/p2p/src/swarm.rs:491-494
Timestamp: 2024-10-11T10:43:34.869Z
Learning: When reviewing revert pull requests in the `hoprnet/hoprnet` repository, avoid making code recommendations or suggestions.
Learnt from: mjadach-iv
PR: hoprnet/hoprnet#6663
File: deploy/compose/.env.sample:57-57
Timestamp: 2024-11-21T13:58:22.345Z
Learning: In code reviews for this project, focus comments on the changes made in the PR, and avoid discussing unrelated code.
Learnt from: NumberFour8
PR: hoprnet/hoprnet#6244
File: transport/protocol/src/ack/processor.rs:31-32
Timestamp: 2024-10-09T06:16:18.170Z
Learning: The GitHub issue to standardize the usage of `METRIC_TICKETS_COUNT` across the codebase was successfully created and can be tracked at https://github.com/hoprnet/hoprnet/issues/6245.
Learnt from: NumberFour8
PR: hoprnet/hoprnet#6244
File: transport/protocol/src/ack/processor.rs:31-32
Timestamp: 2024-07-28T07:26:06.634Z
Learning: The GitHub issue to standardize the usage of `METRIC_TICKETS_COUNT` across the codebase was successfully created and can be tracked at https://github.com/hoprnet/hoprnet/issues/6245.
Learnt from: ausias-armesto
PR: hoprnet/hoprnet#7251
File: .github/workflows/package.yaml:28-28
Timestamp: 2025-06-19T10:07:29.649Z
Learning: In GitHub Actions reusable workflows, the github.event_name context may inherit from the parent workflow rather than being set to 'workflow_call', allowing conditions like 'github.event_name == 'pull_request'' to work correctly when the parent workflow was triggered by a pull_request event.
Learnt from: Teebor-Choka
PR: hoprnet/hoprnet#6886
File: nix/rust-package.nix:84-84
Timestamp: 2025-02-25T00:35:33.437Z
Learning: When transitioning from vendored dependencies to a private proxy registry in Rust projects, GitHub Actions workflows need to be refactored to accommodate the new update strategy, particularly workflows handling dependency updates like renovate-cargo-update.yaml.
Learnt from: ausias-armesto
PR: hoprnet/hoprnet#7251
File: .github/workflows/package.yaml:28-28
Timestamp: 2025-06-19T10:07:29.649Z
Learning: In GitHub Actions reusable workflows, the github context from the caller workflow is inherited by the called workflow, so github.event_name reflects the original triggering event (e.g., 'pull_request') rather than being set to 'workflow_call'. Conditions like 'github.event_name == 'pull_request'' work correctly in reusable workflows when the parent workflow was triggered by that event type.
Learnt from: ausias-armesto
PR: hoprnet/hoprnet#7251
File: .github/workflows/package.yaml:28-28
Timestamp: 2025-06-19T10:08:43.091Z
Learning: In GitHub Actions reusable workflows, the github context from the caller workflow is inherited by the called workflow, so github.event_name reflects the original triggering event (e.g., 'pull_request') rather than being set to 'workflow_call'. Conditions like 'github.event_name == 'pull_request'' work correctly in reusable workflows when the parent workflow was triggered by that event type.
Learnt from: ausias-armesto
PR: hoprnet/hoprnet#7251
File: .github/workflows/package.yaml:28-28
Timestamp: 2025-06-19T10:08:43.091Z
Learning: In GitHub Actions reusable workflows, the github context from the caller workflow is inherited by the called workflow, so github.event_name reflects the original triggering event (e.g., 'pull_request') rather than being set to 'workflow_call'. Conditions like 'github.event_name == 'pull_request'' work correctly in reusable workflows when the parent workflow was triggered by that event type.
Learnt from: ausias-armesto
PR: hoprnet/hoprnet#7191
File: .github/workflows/add-labels.yaml:49-57
Timestamp: 2025-05-27T16:21:03.705Z
Learning: GitHub CLI (gh) accepts GITHUB_TOKEN as an environment variable for authentication in GitHub Actions workflows, not just GH_TOKEN. The environment variable GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} works correctly with gh commands like "gh pr edit".
Learnt from: ausias-armesto
PR: hoprnet/hoprnet#7191
File: .github/workflows/build-dappnode.yaml:40-40
Timestamp: 2025-05-27T16:23:08.868Z
Learning: In the hoprnet repository's GitHub workflows, labels are passed from build.yaml to build-dappnode.yaml with a trailing comma using `format('{0},', join(github.event.pull_request.labels.*.name, ','))`. Therefore, the condition checks in build-dappnode.yaml correctly use `format('package:{0},', inputs.dappnode_repository)` with a trailing comma to match the exact label format and prevent false positives.
Learnt from: ausias-armesto
PR: hoprnet/hoprnet#7280
File: .github/workflows/checks-pre-commit.yaml:30-36
Timestamp: 2025-07-01T13:09:08.718Z
Learning: In the hoprnet repository's GitHub Actions workflow architecture, ausias-armesto prefers to centralize input resolution and fallback logic in the main checks.yaml workflow, which then calls individual reusable workflows like checks-pre-commit.yaml. The individual workflows are designed to be called primarily through the main workflow rather than directly, so fallback values in the individual workflows may be considered redundant.
Learnt from: ausias-armesto
PR: hoprnet/hoprnet#7191
File: .github/workflows/open-pr.yaml:83-95
Timestamp: 2025-06-30T08:36:01.731Z
Learning: The self-hosted-hoprnet-small runners in the hoprnet repository have GitHub CLI (gh) pre-installed and available for use in workflows.
Learnt from: tolbrino
PR: hoprnet/hoprnet#6502
File: flake.nix:12-14
Timestamp: 2024-09-30T08:27:16.849Z
Learning: The project already has CI workflows that automatically check for compatibility issues when updating dependencies, including compiling smart contracts with new Solidity versions, running the test suite, checking for compiler warnings or deprecation notices, and reviewing changelogs for breaking changes.
.github/workflows/build-docker.yaml (10)
Learnt from: ausias-armesto
PR: hoprnet/hoprnet#7191
File: .github/workflows/build-dappnode.yaml:40-40
Timestamp: 2025-05-27T16:23:08.868Z
Learning: In the hoprnet repository's GitHub workflows, labels are passed from build.yaml to build-dappnode.yaml with a trailing comma using `format('{0},', join(github.event.pull_request.labels.*.name, ','))`. Therefore, the condition checks in build-dappnode.yaml correctly use `format('package:{0},', inputs.dappnode_repository)` with a trailing comma to match the exact label format and prevent false positives.
Learnt from: Teebor-Choka
PR: hoprnet/hoprnet#6886
File: nix/rust-package.nix:84-84
Timestamp: 2025-02-25T00:35:33.437Z
Learning: When transitioning from vendored dependencies to a private proxy registry in Rust projects, GitHub Actions workflows need to be refactored to accommodate the new update strategy, particularly workflows handling dependency updates like renovate-cargo-update.yaml.
Learnt from: ausias-armesto
PR: hoprnet/hoprnet#7251
File: .github/workflows/package.yaml:28-28
Timestamp: 2025-06-19T10:07:29.649Z
Learning: In GitHub Actions reusable workflows, the github.event_name context may inherit from the parent workflow rather than being set to 'workflow_call', allowing conditions like 'github.event_name == 'pull_request'' to work correctly when the parent workflow was triggered by a pull_request event.
Learnt from: ausias-armesto
PR: hoprnet/hoprnet#6681
File: .github/workflows/build-binaries.yaml:61-97
Timestamp: 2024-11-26T17:47:32.384Z
Learning: The code in the 'Set environment variables' step in `.github/workflows/build-binaries.yaml` is obsolete and should not be reviewed in future code reviews.
Learnt from: ausias-armesto
PR: hoprnet/hoprnet#7280
File: .github/workflows/checks-pre-commit.yaml:30-36
Timestamp: 2025-07-01T13:09:08.718Z
Learning: In the hoprnet repository's GitHub Actions workflow architecture, ausias-armesto prefers to centralize input resolution and fallback logic in the main checks.yaml workflow, which then calls individual reusable workflows like checks-pre-commit.yaml. The individual workflows are designed to be called primarily through the main workflow rather than directly, so fallback values in the individual workflows may be considered redundant.
Learnt from: ausias-armesto
PR: hoprnet/hoprnet#7251
File: .github/workflows/package.yaml:66-68
Timestamp: 2025-06-19T10:10:00.368Z
Learning: In the HOPR packaging workflow (.github/workflows/package.yaml), the `just package` command creates a single distribution package that includes all binaries (hoprd and hopli) for the target architecture. The workflow downloads both hoprd and hopli artifacts, extracts them to ./dist/bin, and nfpm packages both binaries together into one .deb, .rpm, or .apk file per target.
Learnt from: ausias-armesto
PR: hoprnet/hoprnet#7191
File: .github/workflows/open-pr.yaml:83-95
Timestamp: 2025-06-30T08:36:01.731Z
Learning: The self-hosted-hoprnet-small runners in the hoprnet repository have GitHub CLI (gh) pre-installed and available for use in workflows.
Learnt from: ausias-armesto
PR: hoprnet/hoprnet#7251
File: .github/workflows/package.yaml:0-0
Timestamp: 2025-06-19T11:37:27.410Z
Learning: In the HOPR packaging workflow (.github/workflows/package.yaml), both hoprd and hopli binaries are downloaded and used together in a single package creation process. The `just package` command creates one distribution package (.deb, .rpm, or .apk) per target that contains both binaries, which is why the workflow only uploads one package per format rather than separate packages for each binary.
Learnt from: ausias-armesto
PR: hoprnet/hoprnet#7191
File: .github/workflows/open-pr.yaml:34-43
Timestamp: 2025-06-30T08:33:20.991Z
Learning: In the hoprnet repository, the maintainer ausias-armesto prefers to add commit types to the semantic PR validation workflow incrementally as needed, rather than preemptively adding all possible types. This conservative approach keeps the workflow configuration lean.
Learnt from: ausias-armesto
PR: hoprnet/hoprnet#6635
File: .github/workflows/build-dappnode.yaml:51-52
Timestamp: 2024-11-14T17:33:28.735Z
Learning: In the `.github/workflows/build-dappnode.yaml` file, explicit error handling for GitHub API calls is not required.
⏰ 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). (5)
  • GitHub Check: hoprd / docker
  • GitHub Check: hopli / docker
  • GitHub Check: Docs / Rust
  • GitHub Check: Zizmor / Zizmor
  • GitHub Check: Lint / Lint
🔇 Additional comments (1)
.github/workflows/build-docker.yaml (1)

148-148: Label-match may be too permissive

contains(steps.pr-labels.outputs.labels, 'deploy_nodes') omits the surrounding spaces that are used elsewhere (e.g. the ' release ' check above).
Without the spaces, the expression will also match superset labels such as my-deploy_nodes-test, potentially triggering an unintended production deploy.

-        if: inputs.package == 'hoprd' && vars.CONTINUOUS_DEPLOYMENT_ENABLED == 'true' && contains(steps.pr-labels.outputs.labels, 'deploy_nodes')
+        if: inputs.package == 'hoprd' && vars.CONTINUOUS_DEPLOYMENT_ENABLED == 'true' && contains(steps.pr-labels.outputs.labels, ' deploy_nodes ')

Consider aligning the pattern with the established convention unless you have verified the output format of pr-labels-action for this workflow.

uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.GH_RUNNER_TOKEN }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Ensure GH_RUNNER_TOKEN has repo-scoped repository_dispatch rights

Switching from the default GITHUB_TOKEN to secrets.GH_RUNNER_TOKEN will break the dispatch if the new secret lacks repowrite:repository_dispatch scope or is undefined on all runners. Double-check the secret definition in the repository settings and its permission set before merging.

🤖 Prompt for AI Agents
In .github/workflows/build-docker.yaml at line 151, the secret GH_RUNNER_TOKEN
is used for repository dispatch but may lack the necessary repo-scoped
write:repository_dispatch permission or be undefined. Verify in the repository
settings that GH_RUNNER_TOKEN is properly defined and has the repo scope with
write:repository_dispatch rights to ensure the dispatch action works correctly.

@github-actions github-actions bot added the toolchain Developer and product happiness label Jul 14, 2025
@ausias-armesto
Copy link
Contributor

Implemented also in #7306

auto-merge was automatically disabled July 14, 2025 14:42

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
toolchain Developer and product happiness
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants