From 375ccb1bac89aaa008025d744ac21fe4dca4c060 Mon Sep 17 00:00:00 2001 From: frank zhu Date: Thu, 7 Mar 2024 12:21:26 -0800 Subject: [PATCH] update CI for changeset check (#12212) Co-authored-by: chainchad <96362174+chainchad@users.noreply.github.com> --- .github/workflows/changelog.yml | 40 ------------------------ .github/workflows/changeset.yml | 55 +++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 40 deletions(-) delete mode 100644 .github/workflows/changelog.yml create mode 100644 .github/workflows/changeset.yml diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml deleted file mode 100644 index c9f1b3626b5..00000000000 --- a/.github/workflows/changelog.yml +++ /dev/null @@ -1,40 +0,0 @@ -# -# This action checks PRs to see if any CHANGELOG* files were updated. -# If none were, it will add a message to the PR asking if it would make sense to do so. -# -name: Changelog - -on: pull_request - -jobs: - changelog: - # For security reasons, GITHUB_TOKEN is read-only on forks, so we cannot leave comments on PRs. - # This check skips the job if it is detected we are running on a fork. - if: ${{ github.event.pull_request.head.repo.full_name == 'smartcontractkit/chainlink' }} - name: Changelog checker - runs-on: ubuntu-latest - steps: - - name: Check for changed files - id: changedfiles - uses: umani/changed-files@d7f842d11479940a6036e3aacc6d35523e6ba978 # Version 4.1.0 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - pattern: '^docs/CHANGELOG.*$' - - name: Make a comment - uses: unsplash/comment-on-pr@ffe8f97ccc63ce12c3c23c6885b169db67958d3b # Version 1.3.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: contains(steps.changedfiles.outputs.files_updated, 'CHANGELOG') != true && contains(steps.changedfiles.outputs.files_created, 'CHANGELOG') != true - with: - msg: "I see that you haven't updated any CHANGELOG files. Would it make sense to do so?" - check_for_duplicate_msg: true - - name: Collect Metrics - if: always() - id: collect-gha-metrics - uses: smartcontractkit/push-gha-metrics-action@0281b09807758be1dcc41651e44e62b353808c47 # v2.1.0 - with: - org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }} - basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }} - hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }} - this-job-name: Changelog checker - continue-on-error: true diff --git a/.github/workflows/changeset.yml b/.github/workflows/changeset.yml new file mode 100644 index 00000000000..d7f951bbda3 --- /dev/null +++ b/.github/workflows/changeset.yml @@ -0,0 +1,55 @@ +# +# This action checks PRs to see if any changeset files were added in the PR core files were changed. +# If none were, it will add a comment in the PR to run changeset command to generate a changeset file. +# +name: Changeset + +on: pull_request + +jobs: + changeset: + # For security reasons, GITHUB_TOKEN is read-only on forks, so we cannot leave comments on PRs. + # This check skips the job if it is detected we are running on a fork. + if: ${{ github.event.pull_request.head.repo.full_name == 'smartcontractkit/chainlink' }} + name: Changeset checker + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd # v3.0.0 + id: files-changed + with: + token: ${{ secrets.GITHUB_TOKEN }} + filters: | + shared: &shared + - common/** + - plugins/** + core: + - *shared + - core/** + changeset: + - added: '.changeset/**' + - name: Make a comment + uses: unsplash/comment-on-pr@ffe8f97ccc63ce12c3c23c6885b169db67958d3b # v1.3.0 + if: ${{ steps.files-changed.outputs.core == 'true' && steps.files-changed.outputs.changeset == 'false' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + msg: "I see you updated files related to core. Please run `pnpm changeset` to add a changeset." + check_for_duplicate_msg: true + - name: Check for new changeset + if: ${{ steps.files-changed.outputs.core == 'true' && steps.files-changed.outputs.changeset == 'false' }} + shell: bash + run: | + echo "Please run pnpm changeset to add a changeset." + exit 1 + - name: Collect Metrics + if: always() + id: collect-gha-metrics + uses: smartcontractkit/push-gha-metrics-action@0281b09807758be1dcc41651e44e62b353808c47 # v2.1.0 + with: + org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }} + basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }} + hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }} + this-job-name: Changeset checker + continue-on-error: true