Versioning assets to handle browser cache.
This commit is contained in:
parent
fdb6dcf18c
commit
d3ee905ec2
1 changed files with 28 additions and 0 deletions
|
|
@ -20,6 +20,26 @@ jobs:
|
|||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
-
|
||||
name: Get Metadata
|
||||
id: metadata
|
||||
run: |
|
||||
branchName=${GITHUB_REF#refs/heads/}
|
||||
version=$(date +"%y%m.%d.%H%M%S")
|
||||
tagName=$version
|
||||
preRelease=false
|
||||
if [[ "$branchName" != "master" && "$branchName" != "main" ]]; then
|
||||
tagName="$tagName-$branchName"
|
||||
preRelease=true
|
||||
fi
|
||||
echo "BRANCH_NAME = $branchName"
|
||||
echo "VERSION = $version"
|
||||
echo "TAG_NAME = $tagName"
|
||||
echo "PRERELEASE = $preRelease"
|
||||
echo "BRANCH_NAME=$branchName" >> $GITHUB_OUTPUT
|
||||
echo "VERSION=$version" >> $GITHUB_OUTPUT
|
||||
echo "TAG_NAME=$tagName" >> $GITHUB_OUTPUT
|
||||
echo "PRERELEASE=$preRelease" >> $GITHUB_OUTPUT
|
||||
-
|
||||
name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4.0.0
|
||||
|
|
@ -29,6 +49,14 @@ jobs:
|
|||
-
|
||||
name: Compile CSS
|
||||
run: pnpm run build
|
||||
-
|
||||
name: Append version as query arg to asset URLs
|
||||
env:
|
||||
VERSION: ${{ steps.metadata.outputs.VERSION }}
|
||||
run: |
|
||||
echo "VERSION = $VERSION"
|
||||
find public -type f -name '*.html' -exec sed -i "s/\"\([^\"?]\+\.css\)\"/\"\1?v=$VERSION\"/g" {} +
|
||||
find public -type f -name '*.html' -exec sed -i "s/\"\([^\"?]\+\.js\)\"/\"\1?v=$VERSION\"/g" {} +
|
||||
-
|
||||
name: Copy files to public folder
|
||||
run: mkdir -p /usr/share/nginx/static/fpv; cp -rf public/* /usr/share/nginx/static/fpv
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue