From 478bc4f856c79bf0746f2cb8273d51dcb1ca090f Mon Sep 17 00:00:00 2001 From: Dave Ogle Date: Thu, 21 Nov 2024 09:49:35 +0000 Subject: [PATCH] add job to lint posts on push --- .circleci/config.yml | 2 +- .../check-a11y-of-changed-content.yaml | 4 +-- .github/workflows/lint.yaml | 29 +++++++++++++++++++ package.json | 2 +- 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/lint.yaml diff --git a/.circleci/config.yml b/.circleci/config.yml index b83d3c54c9..bec24753a7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,7 +14,7 @@ jobs: key: v0-blog-yarn-cache-{{ checksum "yarn.lock" }} paths: - ./node_modules - - run: yarn test + - run: yarn lint workflows: version: 2 build_and_test: diff --git a/.github/workflows/check-a11y-of-changed-content.yaml b/.github/workflows/check-a11y-of-changed-content.yaml index beab125321..6ab6d2cee1 100644 --- a/.github/workflows/check-a11y-of-changed-content.yaml +++ b/.github/workflows/check-a11y-of-changed-content.yaml @@ -1,8 +1,8 @@ name: Check accessibility of changed content on: - workflow_dispatch: - pull_request: + pull_request_target: + types: [opened, synchronize, reopened] permissions: contents: read diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000000..046271140d --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,29 @@ +name: Lint Posts + +on: + push: + branches: + - '**' # Runs on pushes to all branches + pull_request: + branches: + - 'gh-pages' # Runs when a PR targets the gh-pages branch + +jobs: + lint-posts: + runs-on: "ubuntu-latest" + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: 20.x + cache: npm + - name: Run install + uses: borales/actions-yarn@v5.0.0 + with: + cmd: install + - name: Run lint + uses: borales/actions-yarn@v5.0.0 + with: + cmd: lint diff --git a/package.json b/package.json index 1544b1c22f..208a8d31e0 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "url": "https://github.com/ScottLogic/blog/issues" }, "scripts": { - "test": "node lintPosts.js", + "lint": "node lintPosts.js", "compute-embeddings": "node scripts/generate-related/compute-embeddings.js", "generate-related": "node scripts/generate-related/blog-metadata.js", "remove-unused-images": "node scripts/images/remove-images.js",