From b026b9edf521976df4b64360698b77a7b0bec7c5 Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Wed, 20 Mar 2024 10:34:14 +0100 Subject: [PATCH 1/3] ci(metadata): remove `fetch-depth: 0` it's not needed anymore --- .github/workflows/gather-pr-metadata.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/gather-pr-metadata.yml b/.github/workflows/gather-pr-metadata.yml index 68c88fb94bc..c3f3d8e6b36 100644 --- a/.github/workflows/gather-pr-metadata.yml +++ b/.github/workflows/gather-pr-metadata.yml @@ -21,8 +21,6 @@ jobs: steps: - name: Repository checkout uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - with: - fetch-depth: 0 - name: Store PR number in file run: | From 254779107579ddaffae8c22ca056c42e2e188c92 Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Wed, 20 Mar 2024 10:32:07 +0100 Subject: [PATCH 2/3] ci(freezer): update metadata and development_freeze workflow use custom action to gather PR metadata and download artifact rather then inline script --- .github/workflows/development_freeze.yml | 43 +++--------------------- .github/workflows/gather-pr-metadata.yml | 15 +++------ 2 files changed, 10 insertions(+), 48 deletions(-) diff --git a/.github/workflows/development_freeze.yml b/.github/workflows/development_freeze.yml index ef4f0b50e98..871f99b2aa5 100644 --- a/.github/workflows/development_freeze.yml +++ b/.github/workflows/development_freeze.yml @@ -8,10 +8,6 @@ on: types: - completed -env: - PULL_REQUEST_METADATA_DIR: pull_request - PULL_REQUEST_METADATA_FILE: metadata - permissions: contents: read @@ -27,40 +23,11 @@ jobs: pull-requests: write steps: - - name: Download Pull Request Metadata artifact - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea + - id: artifact + name: Download Pull Request Metadata artifact + uses: redhat-plumbers-in-action/download-artifact@463ae626ac2dd333491c7beccaa24c12c5c259b8 with: - script: | - const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: ${{ github.event.workflow_run.id }}, - }); - - const matchArtifact = artifacts.data.artifacts.filter((artifact) => { - return artifact.name == "${{ env.PULL_REQUEST_METADATA_FILE }}" - })[0]; - - const download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifact.id, - archive_format: 'zip', - }); - - const fs = require('fs'); - fs.writeFileSync('${{ github.workspace }}/${{ env.PULL_REQUEST_METADATA_FILE }}.zip', Buffer.from(download.data)); - - - run: unzip ${{ env.PULL_REQUEST_METADATA_FILE }}.zip - - - name: 'Get Pull Request number' - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const fs = require('fs'); - const pr_number = Number(fs.readFileSync('./${{ env.PULL_REQUEST_METADATA_FILE }}')); - core.exportVariable('pr_number', pr_number); + name: Pull Request Metadata - name: Repository checkout uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 @@ -70,5 +37,5 @@ jobs: - name: Development Freezer uses: redhat-plumbers-in-action/devel-freezer@67aec4a153bd9fca5322e1c4dd4d7c419fb36362 with: - pr-number: ${{ env.pr_number }} + pr-number: ${{ fromJSON(steps.artifact.outputs.pr-metadata-json).number }} token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/gather-pr-metadata.yml b/.github/workflows/gather-pr-metadata.yml index c3f3d8e6b36..ae5921aac46 100644 --- a/.github/workflows/gather-pr-metadata.yml +++ b/.github/workflows/gather-pr-metadata.yml @@ -6,10 +6,6 @@ on: pull_request: branches: [ main ] -env: - PULL_REQUEST_METADATA_DIR: pull_request - PULL_REQUEST_METADATA_FILE: metadata - permissions: contents: read @@ -22,14 +18,13 @@ jobs: - name: Repository checkout uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - - name: Store PR number in file - run: | - mkdir -p ./${{ env.PULL_REQUEST_METADATA_DIR }} - echo ${{ github.event.number }} >./${{ env.PULL_REQUEST_METADATA_DIR }}/${{ env.PULL_REQUEST_METADATA_FILE }} + - id: metadata + name: Gather Pull Request Metadata + uses: redhat-plumbers-in-action/gather-pull-request-metadata@69c703f376018c1a41c8ccce21dc2e16a79f3324 - name: Upload Pull Request Metadata artifact uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 with: - name: ${{ env.PULL_REQUEST_METADATA_FILE }} - path: ${{ env.PULL_REQUEST_METADATA_DIR }} + name: Pull Request Metadata + path: ${{ steps.metadata.outputs.metadata-file }} retention-days: 1 From ec8c80eddbe530e042a1ee27f21a6daa3e2c50b1 Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Wed, 20 Mar 2024 12:37:18 +0100 Subject: [PATCH 3/3] ci(freezer): update `devel-freezer` GHA to `v1.1.0` The new version of `devel-freezer` GitHub Action adds support for milestones, labels, and more. Now, when the `rc` tag is published, it won't post a development freeze comment on PRs included in the next milestone. This commit also sets a delay of the 20s for PR validation to give some time for updating labels and milestones on submitted PRs. --- .github/workflows/development_freeze.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/development_freeze.yml b/.github/workflows/development_freeze.yml index 871f99b2aa5..f9738d0ffea 100644 --- a/.github/workflows/development_freeze.yml +++ b/.github/workflows/development_freeze.yml @@ -35,7 +35,9 @@ jobs: fetch-depth: 0 - name: Development Freezer - uses: redhat-plumbers-in-action/devel-freezer@67aec4a153bd9fca5322e1c4dd4d7c419fb36362 + uses: redhat-plumbers-in-action/devel-freezer@396c94ba8cb417474e6626c83a42addea210a403 with: pr-number: ${{ fromJSON(steps.artifact.outputs.pr-metadata-json).number }} + # delay start of validation to allow for some milestone/labels tweaking + delay: 20 token: ${{ secrets.GITHUB_TOKEN }}