From 53dfedebbfcd602b45968a86eb432e4fa645217c Mon Sep 17 00:00:00 2001 From: Kevin J Hoerr Date: Sun, 24 Dec 2023 00:15:17 -0500 Subject: Update workflow for updating build version --- .github/workflows/build.yml | 8 ++++---- src/config.ts | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6aca8a8..05d1b2c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,12 +27,12 @@ jobs: id: date run: echo "DATE_VERSION=$(date +'%s')" >> $GITHUB_OUTPUT - name: Modify version number - uses: mingjun97/file-regex-replace@v1 if: steps.filter.outputs.source == 'true' + uses: jacobtomlinson/gha-find-replace@v3 with: - regex: '"version": "[0-9]*",' - replacement: '"version": "${{ steps.date.outputs.DATE_VERSION }}",' - include: 'config\.json' + find: '"version": "[0-9]*",' + replace: '"version": "${{ steps.date.outputs.DATE_VERSION }}",' + include: 'config.json' - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 diff --git a/src/config.ts b/src/config.ts index 3fdcf24..b0ad1b0 100644 --- a/src/config.ts +++ b/src/config.ts @@ -6,9 +6,13 @@ export default function (eleventyConfig: any) { eleventyConfig.addPassthroughCopy({ "./src/static/": "/", }); + + // hook in configured build time for GH action to update eleventyConfig.addGlobalData("buildTimeEncoded", () => { return getTimestamp(Number(BuildInfo.version)); }); + + // ensure eleventy marks this config as watched, since it's typescript eleventyConfig.addWatchTarget("./src/config.ts"); return { -- cgit