CI: Fix release-comms workflow (#104968)

* pass around github_token
pull/105559/head
Kevin Minehart 2 months ago committed by GitHub
parent 77e1acaf3f
commit 9e08471858
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      .github/workflows/changelog.yml
  2. 2
      .github/workflows/community-release.yml
  3. 9
      .github/workflows/github-release.yml
  4. 17
      .github/workflows/release-comms.yml
  5. 66
      .github/workflows/release-pr.yml
  6. 3
      .github/zizmor.yml

@ -81,13 +81,13 @@ jobs:
ref: main ref: main
sparse-checkout: | sparse-checkout: |
.github/workflows .github/workflows
.github/actions
CHANGELOG.md CHANGELOG.md
.nvmrc .nvmrc
.prettierignore .prettierignore
.prettierrc.js .prettierrc.js
fetch-depth: 0 fetch-depth: 0
fetch-tags: true fetch-tags: true
persist-credentials: false
- name: Setup nodejs environment - name: Setup nodejs environment
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:

@ -37,7 +37,6 @@ jobs:
with: with:
# Secrets placed in the ci/repo/grafana/grafana/community_release path in Vault # Secrets placed in the ci/repo/grafana/grafana/community_release path in Vault
repo_secrets: | repo_secrets: |
GRAFANA_MISC_STATS_API_KEY=community_release:GRAFANA_MISC_STATS_API_KEY
GRAFANABOT_FORUM_KEY=community_release:GRAFANABOT_FORUM_KEY GRAFANABOT_FORUM_KEY=community_release:GRAFANABOT_FORUM_KEY
- name: Run community-release (manually invoked) - name: Run community-release (manually invoked)
@ -45,7 +44,6 @@ jobs:
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ inputs.version }} version: ${{ inputs.version }}
metrics_api_key: ${{ env.GRAFANA_MISC_STATS_API_KEY }}
community_api_key: ${{ env.GRAFANABOT_FORUM_KEY }} community_api_key: ${{ env.GRAFANABOT_FORUM_KEY }}
community_api_username: grafanabot community_api_username: grafanabot
dry_run: ${{ inputs.dry_run }} dry_run: ${{ inputs.dry_run }}

@ -40,19 +40,10 @@ jobs:
main: main:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: "Get vault secrets"
id: vault-secrets
uses: grafana/shared-workflows/actions/get-vault-secrets@main
with:
# Secrets placed in the ci/repo/grafana/grafana/github_release path in Vault
repo_secrets: |
GRAFANA_MISC_STATS_API_KEY=github_release:GRAFANA_MISC_STATS_API_KEY
- name: Create GitHub release (manually invoked) - name: Create GitHub release (manually invoked)
uses: grafana/grafana-github-actions-go/github-release@main # zizmor: ignore[unpinned-uses] uses: grafana/grafana-github-actions-go/github-release@main # zizmor: ignore[unpinned-uses]
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ inputs.version }} version: ${{ inputs.version }}
metrics_api_key: ${{ env.GRAFANA_MISC_STATS_API_KEY }}
latest: ${{ inputs.latest }} latest: ${{ inputs.latest }}
dry_run: ${{ inputs.dry_run }} dry_run: ${{ inputs.dry_run }}

@ -21,13 +21,13 @@ on:
- 'main' - 'main'
- 'release-*.*.*' - 'release-*.*.*'
permissions: {} permissions:
contents: write
pull-requests: write
id-token: write
jobs: jobs:
setup: setup:
permissions:
contents: read
id-token: write
if: ${{ github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/')) }} if: ${{ github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/')) }}
name: Setup and establish latest name: Setup and establish latest
outputs: outputs:
@ -35,6 +35,8 @@ jobs:
release_branch: ${{ steps.output.outputs.release_branch }} release_branch: ${{ steps.output.outputs.release_branch }}
dry_run: ${{ steps.output.outputs.dry_run }} dry_run: ${{ steps.output.outputs.dry_run }}
latest: ${{ steps.output.outputs.latest }} latest: ${{ steps.output.outputs.latest }}
private_key: ${{ steps.output.outputs.delivery_bot_pem }}
app_id: ${{ vars.DELIVERY_BOT_APP_ID }}
env: env:
HEAD_REF: ${{ github.head_ref }} HEAD_REF: ${{ github.head_ref }}
DRY_RUN: ${{ inputs.dry_run }} DRY_RUN: ${{ inputs.dry_run }}
@ -42,6 +44,13 @@ jobs:
VERSION: ${{ inputs.version }} VERSION: ${{ inputs.version }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: "Get vault secrets"
id: vault-secrets
uses: grafana/shared-workflows/actions/get-vault-secrets@main
with:
# Secrets placed in the ci/data/repo/grafana/grafana/delivery-bot-app path in Vault
repo_secrets: |
GRAFANA_DELIVERY_BOT_APP_PEM=delivery-bot-app:PRIVATE_KEY
- if: ${{ github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') }} - if: ${{ github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') }}
run: | run: |
{ {

@ -15,15 +15,19 @@ on:
version: version:
required: true required: true
type: string type: string
description: The version of Grafana that is being released description: The version of Grafana that is being released (without the `v` prefix)`
target: target:
required: true required: true
type: string type: string
description: The release branch pattern (eg v9.5.x) that these changes are being merged into description: The release branch pattern (eg v9.5.x) that these changes are being merged into
backport: changelog:
required: false required: false
type: string type: boolean
description: Branch to backport these changes to default: true
bump:
required: false
type: boolean
default: true
dry_run: dry_run:
required: false required: false
default: false default: false
@ -41,6 +45,7 @@ jobs:
push-changelog-to-main: push-changelog-to-main:
permissions: permissions:
contents: write contents: write
id-token: write
pull-requests: write pull-requests: write
name: Create PR to main to update the changelog name: Create PR to main to update the changelog
uses: ./.github/workflows/changelog.yml uses: ./.github/workflows/changelog.yml
@ -54,6 +59,7 @@ jobs:
create-prs: create-prs:
permissions: permissions:
contents: write contents: write
id-token: write
pull-requests: write pull-requests: write
name: Create Release PR name: Create Release PR
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -70,29 +76,20 @@ jobs:
# Secrets placed in the ci/data/repo/grafana/grafana/delivery-bot-app path in Vault # Secrets placed in the ci/data/repo/grafana/grafana/delivery-bot-app path in Vault
repo_secrets: | repo_secrets: |
GRAFANA_DELIVERY_BOT_APP_PEM=delivery-bot-app:PRIVATE_KEY GRAFANA_DELIVERY_BOT_APP_PEM=delivery-bot-app:PRIVATE_KEY
- name: Get release branch - run: echo "RELEASE_BRANCH=release-${VERSION}" >> "$GITHUB_ENV"
id: branch
uses: grafana/grafana-github-actions-go/latest-release-branch@main # zizmor: ignore[unpinned-uses]
with:
token: ${{ secrets.GITHUB_TOKEN }}
ownerRepo: 'grafana/grafana'
pattern: ${{ inputs.target }}
- name: Checkout Grafana - name: Checkout Grafana
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
ref: ${{ steps.branch.outputs.branch }} ref: ${{ env.RELEASE_BRANCH }}
fetch-tags: true fetch-tags: true
token: ${{ secrets.GITHUB_TOKEN }} fetch-depth: 0
persist-credentials: false
- name: Checkout Grafana (main) - name: Checkout Grafana (main)
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
ref: main ref: main
fetch-depth: '0' fetch-depth: '0'
fetch-tags: 'false'
path: .grafana-main path: .grafana-main
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false
- name: Setup nodejs environment - name: Setup nodejs environment
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
@ -104,8 +101,9 @@ jobs:
git config --local --add --bool push.autoSetupRemote true git config --local --add --bool push.autoSetupRemote true
- name: Create branch - name: Create branch
run: git checkout -b "release/${{ github.run_id }}/$VERSION" run: git checkout -b "release/${{ github.run_number }}/$VERSION"
- name: Generate changelog token - name: Generate changelog token
if: ${{ inputs.changelog == true || inputs.changelog == 'true' }}
id: generate_changelog_token id: generate_changelog_token
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92 uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92
with: with:
@ -113,12 +111,15 @@ jobs:
private_key: ${{ env.GRAFANA_DELIVERY_BOT_APP_PEM }} private_key: ${{ env.GRAFANA_DELIVERY_BOT_APP_PEM }}
- name: Generate changelog - name: Generate changelog
id: changelog id: changelog
if: ${{ inputs.changelog == true || inputs.changelog == 'true' }}
uses: ./.grafana-main/.github/actions/changelog uses: ./.grafana-main/.github/actions/changelog
with: with:
previous: ${{inputs.previous_version}}
github_token: ${{ steps.generate_changelog_token.outputs.token }} github_token: ${{ steps.generate_changelog_token.outputs.token }}
target: v${{ env.VERSION }} target: v${{ env.VERSION }}
output_file: changelog_items.md output_file: changelog_items.md
- name: Patch CHANGELOG.md - name: Patch CHANGELOG.md
if: ${{ inputs.changelog == true || inputs.changelog == 'true' }}
run: | run: |
# Prepare CHANGELOG.md content with version delimiters # Prepare CHANGELOG.md content with version delimiters
( (
@ -150,16 +151,20 @@ jobs:
git diff CHANGELOG.md git diff CHANGELOG.md
- name: "Prettify CHANGELOG.md" - name: "Prettify CHANGELOG.md"
if: ${{ inputs.changelog == true || inputs.changelog == 'true' }}
run: npx prettier --write CHANGELOG.md run: npx prettier --write CHANGELOG.md
- name: Commit CHANGELOG.md changes - name: Commit CHANGELOG.md changes
if: ${{ inputs.changelog == true || inputs.changelog == 'true' }}
run: git add CHANGELOG.md && git commit --allow-empty -m "Update changelog" CHANGELOG.md run: git add CHANGELOG.md && git commit --allow-empty -m "Update changelog" CHANGELOG.md
- name: Update package.json versions - name: Update package.json versions
if: ${{ inputs.bump == true || inputs.bump == 'true' }}
uses: ./.grafana-main/pkg/build/actions/bump-version uses: ./.grafana-main/pkg/build/actions/bump-version
with: with:
version: 'patch' version: 'patch'
- name: Add package.json changes - name: Add package.json changes
if: ${{ inputs.bump == true || inputs.bump == 'true' }}
run: | run: |
git add package.json lerna.json yarn.lock packages public git add package.json lerna.json yarn.lock packages public
test -e e2e/test-plugins && git add e2e/test-plugins test -e e2e/test-plugins && git add e2e/test-plugins
@ -167,28 +172,8 @@ jobs:
- name: Git push - name: Git push
if: inputs.dry_run != true if: inputs.dry_run != true
run: git push --set-upstream origin "release/${{ github.run_id }}/$VERSION" run: git push
- name: Create PR
- name: Create PR without backports
if: "${{ inputs.backport == '' }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: ${{ steps.branch.outputs.branch }}
run: |
LATEST_FLAG=""
if [ "$LATEST" = "true" ]; then
LATEST_FLAG=(-l "release/latest")
fi
gh pr create \
"${LATEST_FLAG[@]}" \
-l "no-changelog" \
--dry-run="$DRY_RUN" \
-B "$BRANCH" \
--title "Release: $VERSION" \
--body "These code changes must be merged after a release is complete"
- name: Create PR with backports
if: "${{ inputs.backport != '' }}"
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: ${{ steps.branch.outputs.branch }} BRANCH: ${{ steps.branch.outputs.branch }}
@ -199,7 +184,6 @@ jobs:
fi fi
gh pr create \ gh pr create \
"${LATEST_FLAG[@]}" \ "${LATEST_FLAG[@]}" \
-l "product-approved" \
-l "no-changelog" \ -l "no-changelog" \
--dry-run="$DRY_RUN" \ --dry-run="$DRY_RUN" \
-B "$BRANCH" \ -B "$BRANCH" \

@ -29,3 +29,6 @@ rules:
- pr-commands.yml - pr-commands.yml
- pr-patch-check-event.yml - pr-patch-check-event.yml
- run-dashboard-search-e2e.yml - run-dashboard-search-e2e.yml
excessive-permissions:
ignore:
- release-comms.yml

Loading…
Cancel
Save