From 9ac1907f10810971229bf5437872bce2c9d87c74 Mon Sep 17 00:00:00 2001 From: Dawid Urbas Date: Tue, 30 Jan 2024 16:47:36 +0000 Subject: [PATCH] Test fix script --- .github/workflows/test.yaml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0f50476..840c3db 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,8 +11,30 @@ jobs: name: test steps: + - name: Check version against latest release in Chrome Web Store + id: check_version + uses: actions/github-script@v6 + with: + script: | + const fs = require('fs'); + const fetch = require('node-fetch'); + const manifest = JSON.parse(fs.readFileSync('./static/manifest.json', 'utf8')); + const currentVersion = manifest.version; + const response = await fetch(`https://chrome.google.com/webstore/detail/${{ secrets.CHROME_CLIENT_ID }}?hl=en`); + const text = await response.text(); + const match = text.match(/"version": "(\d+\.\d+\.\d+)"/); + const latestVersion = match ? match[1] : null; + if (currentVersion === latestVersion) { + core.setOutput('abort', 'true'); + } else { + core.setOutput('abort', 'false'); + } + - name: Abort build if version matches + if: steps.check_version.outputs.abort == 'true' + run: | + echo "Version in manifest matches the latest release version in Chrome Web Store. Aborting build." + exit 1 - uses: actions/checkout@v4 - - name: Setup Node.js environment uses: actions/setup-node@v3 with: