From d099770d0bd24a8a3e6e0c3d4c46a3095abd997d Mon Sep 17 00:00:00 2001 From: Kevin Minehart Date: Tue, 22 Apr 2025 08:34:47 -0500 Subject: [PATCH] update PR patch check / sync mirror workflows --- .github/workflows/pr-patch-check-event.yml | 49 ++++++++++++++++++++++ .github/workflows/pr-patch-check.yml | 27 ------------ .github/workflows/sync-mirror-event.yml | 43 +++++++++++++++++++ .github/workflows/sync-mirror.yml | 25 ----------- 4 files changed, 92 insertions(+), 52 deletions(-) create mode 100644 .github/workflows/pr-patch-check-event.yml delete mode 100644 .github/workflows/pr-patch-check.yml create mode 100644 .github/workflows/sync-mirror-event.yml delete mode 100644 .github/workflows/sync-mirror.yml diff --git a/.github/workflows/pr-patch-check-event.yml b/.github/workflows/pr-patch-check-event.yml new file mode 100644 index 00000000000..03dd31a7539 --- /dev/null +++ b/.github/workflows/pr-patch-check-event.yml @@ -0,0 +1,49 @@ +# Owned by grafana-delivery-squad +# Intended to be dropped into the base repo Ex: grafana/grafana +name: Dispatch check for patch conflicts +run-name: dispatch-check-patch-conflicts-${{ github.base_ref }}-${{ github.head_ref }} +on: + pull_request: + types: + - opened + - reopened + - synchronize + branches: + - "main" + - "v*.*.*" + - "release-*" + +# Since this is run on a pull request, we want to apply the patches intended for the +# target branch onto the source branch, to verify compatibility before merging. +jobs: + dispatch-job: + runs-on: ubuntu-latest + steps: + - name: "Generate token" + id: generate_token + uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a + with: + # App needs Actions: Read/Write for the grafana/security-patch-actions repo + app_id: ${{ secrets.GRAFANA_DELIVERY_BOT_APP_ID }} + private_key: ${{ secrets.GRAFANA_DELIVERY_BOT_APP_PEM }} + + - name: "Dispatch job" + uses: actions/github-script@v7 + with: + github-token: ${{ steps.generate_token.outputs.token }} + script: | + await github.rest.actions.createWorkflowDispatch({ + owner: 'grafana', + repo: 'security-patch-actions', + workflow_id: 'test-patches-event.yml', + ref: 'main', + inputs: { + src_repo: "${{ github.repository }}", + src_ref: "${{ github.head_ref }}", + src_merge_sha: "${{ github.sha }}", + src_pr_commit_sha: "${{ github.event.pull_request.head.sha }}", + patch_repo: "${{ github.repository }}-security-patches", + patch_ref: "${{ github.base_ref }}", + triggering_github_handle: "${{ github.event.sender.login }}" + } + }) diff --git a/.github/workflows/pr-patch-check.yml b/.github/workflows/pr-patch-check.yml deleted file mode 100644 index ef1009b7545..00000000000 --- a/.github/workflows/pr-patch-check.yml +++ /dev/null @@ -1,27 +0,0 @@ -# Owned by grafana-release-guild -# Intended to be dropped into the base repo Ex: grafana/grafana -name: Check for patch conflicts -run-name: check-patch-conflicts-${{ github.base_ref }}-${{ github.head_ref }} -on: - pull_request: - types: - - opened - - reopened - - synchronize - branches: - - "main" - - "v*.*.*" - - "release-*" - -# Since this is run on a pull request, we want to apply the patches intended for the -# target branch onto the source branch, to verify compatibility before merging. -jobs: - trigger_downstream_patch_check: - uses: grafana/security-patch-actions/.github/workflows/test-patches.yml@main - if: github.repository == 'grafana/grafana' - with: - src_repo: "${{ github.repository }}" - src_ref: "${{ github.head_ref }}" # this is the source branch name, Ex: "feature/newthing" - patch_repo: "${{ github.repository }}-security-patches" - patch_ref: "${{ github.base_ref }}" # this is the target branch name, Ex: "main" - secrets: inherit diff --git a/.github/workflows/sync-mirror-event.yml b/.github/workflows/sync-mirror-event.yml new file mode 100644 index 00000000000..b1a1466fdf9 --- /dev/null +++ b/.github/workflows/sync-mirror-event.yml @@ -0,0 +1,43 @@ +# Owned by grafana-delivery-squad +# Intended to be dropped into the base repo, Ex: grafana/grafana +name: Dispatch sync to mirror +run-name: dispatch-sync-to-mirror-${{ github.ref_name }} +on: + workflow_dispatch: + push: + branches: + - "main" + - "v*.*.*" + - "release-*" + +# This is run after the pull request has been merged, so we'll run against the target branch +jobs: + dispatch-job: + runs-on: ubuntu-latest + steps: + - name: "Generate token" + id: generate_token + uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a + with: + # App needs Actions: Read/Write for the grafana/security-patch-actions repo + app_id: ${{ secrets.GRAFANA_DELIVERY_BOT_APP_ID }} + private_key: ${{ secrets.GRAFANA_DELIVERY_BOT_APP_PEM }} + + - uses: actions/github-script@v7 + if: github.repository == 'grafana/grafana' + with: + github-token: ${{ steps.generate_token.outputs.token }} + script: | + await github.rest.actions.createWorkflowDispatch({ + owner: 'grafana', + repo: 'security-patch-actions', + workflow_id: 'mirror-branch-and-apply-patches-event.yml', + ref: 'main', + inputs: { + src_ref: "${{ github.ref_name }}", + src_repo: "${{ github.repository }}", + src_sha: "${{ github.sha }}", + dest_repo: "${{ github.repository }}-security-mirror", + patch_repo: "${{ github.repository }}-security-patches" + } + }) diff --git a/.github/workflows/sync-mirror.yml b/.github/workflows/sync-mirror.yml deleted file mode 100644 index 09c8f87d509..00000000000 --- a/.github/workflows/sync-mirror.yml +++ /dev/null @@ -1,25 +0,0 @@ -# Owned by grafana-release-guild -# Intended to be dropped into the base repo, Ex: grafana/grafana -name: Sync to mirror -run-name: sync-to-mirror-${{ github.ref_name }} -on: - workflow_dispatch: - push: - branches: - - "main" - - "v*.*.*" - - "release-*" - -# This is run after the pull request has been merged, so we'll run against the target branch -jobs: - trigger_downstream_patch_mirror: - concurrency: patch-mirror-${{ github.ref_name }} - uses: grafana/security-patch-actions/.github/workflows/mirror-branch-and-apply-patches.yml@main - if: github.repository == 'grafana/grafana' - with: - ref: "${{ github.ref_name }}" # this is the target branch name, Ex: "main" - src_repo: "${{ github.repository }}" - dest_repo: "${{ github.repository }}-security-mirror" - patch_repo: "${{ github.repository }}-security-patches" - secrets: inherit -