From cfe269ebd9a507e0087e18b5b190b3a9265623c4 Mon Sep 17 00:00:00 2001 From: Ray Epps Date: Tue, 8 Nov 2022 18:45:14 -0700 Subject: [PATCH] Add CI/CD step to check cdn files are up to date (#148) * check cdn files match the source * base64 encode checksum result * trim new lines on checksum output --- .github/workflows/test-on-pr.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/.github/workflows/test-on-pr.yml b/.github/workflows/test-on-pr.yml index cd88c584..e5ed542d 100644 --- a/.github/workflows/test-on-pr.yml +++ b/.github/workflows/test-on-pr.yml @@ -25,3 +25,34 @@ jobs: node-version: '16.x' - run: yarn - run: yarn format:check + verify-cdn-build-matches-src: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '16.x' + - run: yarn + - run: npm install -g checksum + - name: Calc current cdn checksums + id: current-checksums + run: echo "checksums=$(checksum cdn/* | base64 | tr '\n' ' ')" >> $GITHUB_OUTPUT + - run: yarn build + - name: Calc built cdn checksums + id: built-checksums + run: echo "checksums=$(checksum cdn/* | base64 | tr '\n' ' ')" >> $GITHUB_OUTPUT + - uses: actions/github-script@v6 + env: + CURRENT_CHECKSUMS: ${{steps.current-checksums.outputs.checksums}} + BUILT_CHECKSUMS: ${{steps.built-checksums.outputs.checksums}} + with: + script: | + const { + CURRENT_CHECKSUMS: current, + BUILT_CHECKSUMS: built + } = process.env + if (current.trim() !== built.trim()) { + core.setFailed(`The files in the cdn directory don't match the expected output given the source. Maybe you didn't run yarn build before pushing?`) + } else { + core.debug(`Success, the cdn build files reflect the current source code.`) + }