diff --git a/.eslintrc.js b/.eslintrc.js index 545adecb4..20b59f428 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,4 +1,5 @@ module.exports = { + root: true, extends: [ 'plugin:@wordpress/eslint-plugin/recommended', 'plugin:eslint-comments/recommended', diff --git a/.github/workflows/lint-js-css.yml b/.github/workflows/lint-js-css.yml new file mode 100644 index 000000000..19a4806b3 --- /dev/null +++ b/.github/workflows/lint-js-css.yml @@ -0,0 +1,50 @@ +name: Lint JS and CSS + +on: + # Run on pushes to develop and on all pull requests. + push: + branches: + - develop + pull_request: + # Allow manually triggering the workflow. + workflow_dispatch: + +# Cancels all previous workflow runs for the same branch that have not yet completed. +concurrency: + # The concurrency group contains the workflow name and the branch name. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + lint-js-css: + name: "Lint: JS and CSS" + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 + with: + persist-credentials: false + + - name: Setup Node.js + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 + with: + node-version: 20 + cache: 'npm' + + - name: Install dependencies + env: + # No git hooks needed in CI. + HUSKY: 0 + run: npm ci + + - name: Lint JavaScript + run: npm run lint:js + + # Run the CSS lint even when the JS lint fails, so one run reports both. + - name: Lint CSS + if: ${{ !cancelled() }} + run: npm run lint:css diff --git a/.github/workflows/sbom.yml b/.github/workflows/sbom.yml new file mode 100644 index 000000000..0100d7111 --- /dev/null +++ b/.github/workflows/sbom.yml @@ -0,0 +1,47 @@ +name: Generate SBOM + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + generate_sbom: + name: Generate and attach SBOM + runs-on: ubuntu-latest + permissions: + # Needed to upload the SBOM to the release. + contents: write + steps: + - name: Checkout release + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 + with: + persist-credentials: false + + - name: Install Syft + env: + DOWNLOAD_TAG_INSTALL_SCRIPT: "false" + run: | + curl -sSfL https://raw.githubusercontent.com/anchore/syft/a0c0d3890a9d79421c403e8fcadec50a2e55bf21/install.sh -o "$RUNNER_TEMP/install-syft.sh" + sh "$RUNNER_TEMP/install-syft.sh" -b "$RUNNER_TEMP/bin" v1.57.1 + echo "$RUNNER_TEMP/bin" >> "$GITHUB_PATH" + + # Scan the release source, including the Composer and npm lock files. + # deploy.yml alone deploys to WordPress.org and uploads the plugin ZIP; + # this workflow only adds the SBOM file to the same release. + - name: Generate SBOM + env: + RELEASE_TAG: ${{ github.event.release.tag_name }} + run: syft . -o "cyclonedx-json=sbom-$RELEASE_TAG.json" + + - name: Upload SBOM to release + uses: softprops/action-gh-release@8a0cd651e5b2365bd640854a3fa5dfc70e4875f3 # v3.0.4 + with: + files: sbom-${{ github.event.release.tag_name }}.json + fail_on_unmatched_files: true + append_body: true + body: | + SBOM Format: CycloneDX JSON + Generated with: Syft