Skip to content

Conversation

@xnyo
Copy link
Collaborator

@xnyo xnyo commented Nov 11, 2025

Add support for publishing to prod from non-main branches, including tags.

Adds two new inputs to cd.yml:

  • release-reference-regex: a regex that will be used to match against the provided branch input (which can be a branch or tag, e.g.: v1.2.4 or release/v1.2.4). If it matches, releasing to prod or prod-canary is allowed, otherwise it fails the job when targeting prod or prod-canary. Defaults to main.
  • allow-publishing-prs-to-prod: if true, allow releasing to prod or prod-canary from a release branch even if there is an open (unmerged) PR for that branch. Defaults to false (which will fail the workflow) as a fail-safe

Part of #133 and https://github.com/grafana/grafana-community-team/issues/534

Example run is in the grafana-pluginsplatformprovisioned-app repository: Example run releasing tag v1.2.4 to prod: https://github.com/grafana/grafana-pluginsplatformprovisioned-app/actions/runs/19370162660

In the test run, release-branch-regex is set to (main)|(giuseppe\/.+)|(v\d+\.\d+\.\d+): https://github.com/grafana/grafana-pluginsplatformprovisioned-app/blob/cd58518042c316f479b0c73a7934421c597549ab/.github/workflows/publish.yaml#L35

⚠️ Breaking change

Calls to cd.yml must be adjusted to include an additional permission: pull-requests: read, otherwise the workflow will fail with the following error:

Invalid workflow file: ...
The workflow is not valid. .github/workflows/publish.yaml (...): Error calling workflow 'grafana/plugin-ci-workflows/.github/workflows/cd.yml@.... The workflow is requesting 'pull-requests: read', but is only allowed 'pull-requests: none'.

Example on the required changes to cd.yml:

jobs:
  cd:
    name: CD
    uses: grafana/plugin-ci-workflows/.github/workflows/cd.yml@main
    permissions:
      contents: write
+     pull-requests: read
      id-token: write
      attestations: write

@xnyo xnyo self-assigned this Nov 11, 2025
@xnyo xnyo added the enhancement New feature or request label Nov 11, 2025
@xnyo xnyo moved this from 📬 Triage to 🧑‍💻 In development in Plugins Platform / Grafana Community Nov 11, 2025
@xnyo xnyo changed the title feat: allow releasing to prod from non-main branches feat(cd)!: allow releasing to prod from non-main branches Nov 14, 2025
# Options for deploying PRs. Those values should come from the PR event and should not be set manually.
branch:
description: Branch to publish from. Can be used to deploy PRs to dev.
description: Branch or tag to publish from. Can be used to deploy PRs to dev.

Choose a reason for hiding this comment

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

Maybe update "Can be used to deploy PRs to dev" so it's clearer that this will now be able to be used on the rare instance need to deploy to another env?

If true, allows branches with open PRs to deploy to `prod` environment.
It's recommended to keep this false to avoid deploying unreviewed code to production.
Default is false.
default: false

Choose a reason for hiding this comment

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

Is there a possibility to input the prod instance we'd want to deploy to? Just wondering what the workflow would look like to deploy to a single prod instance, especially compared to a gcom CLI command like this, where we have the zip file and tell it which instance to deploy to:

 gcom /instances/catperry/provisioned-plugins/grafana-collector-app --data-urlencode urlTemplate='https://storage.googleapis.com/integration-artifacts/grafana-collector-app/4.3.0/catperry-create-reader-rbac-role/34c8cb05/artifacts/grafana-collector-app-4.3.0.any.zip' --data-urlencode version='4.3.0+34c8cb05'

echo "plugin_version_suffix=" >> "$GITHUB_OUTPUT"
fi
fi
- name: Define variables
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Most of the code of this step has been moved from the "define-variables" step. This step now runs before CI and has been changed to output values that are used for detecting release branches

plugin-version-suffix: ${{ steps.vars.outputs.plugin-version-suffix }}
platforms: ${{ steps.vars.outputs.platforms }}
steps:
- name: Check environment
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These checks have been moved into the new "Define variables" step below

with:
subject-path: /tmp/dist-artifacts/*.zip

define-variables:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As per the other comment, this job has been moved into a step of the "setup" job instead, and it now runs before CI

@xnyo xnyo marked this pull request as ready for review November 17, 2025 12:19
@xnyo xnyo requested review from a team as code owners November 17, 2025 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: 🧑‍💻 In development

Development

Successfully merging this pull request may close these issues.

2 participants