Skip to content

Commit

Permalink
Update githubpages.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
sungaila authored Sep 1, 2023
1 parent c64a99f commit 1ff984f
Showing 1 changed file with 6 additions and 35 deletions.
41 changes: 6 additions & 35 deletions .github/workflows/githubpages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,50 +26,21 @@ jobs:
run: dotnet workload install android
- name: Setup .NET workload wasm-tools
run: dotnet workload install wasm-tools
- name: Restore
run: dotnet restore src/PDFtoImage.sln
- name: Publish
run: dotnet publish src/WebConverter/WebConverter.csproj -c Release -p:PublishProfile=src/WebConverter/Properties/PublishProfiles/PublishSite.pubxml --no-restore
- name: Update relative paths
working-directory: src/WebConverter/bin/Release/net7.0/publish/wwwroot
working-directory: src/WebConverter/wwwroot
run: |
sed -i 's/<base href="\/" \/>/<base href="\/${{github.event.repository.name}}\/" \/>/g' index.html
sed -i 's/"scope": "\/"/"scope": "\/${{github.event.repository.name}}\/"/g' manifest.webmanifest
sed -i 's/"start_url": "\/"/"start_url": "\/${{github.event.repository.name}}\/"/g' manifest.webmanifest
sed -i 's/"action": "\/"/"action": "\/${{github.event.repository.name}}\/"/g' manifest.webmanifest
sed -i 's/"action": "\/receive-webshare"/"action": "\/${{github.event.repository.name}}\/receive-webshare"/g' manifest.webmanifest
sed -i 's/return Response.redirect('\/', 303)/return Response.redirect('\/${{github.event.repository.name}}\/', 303)/g' service-worker.published.js
- name: Restore
run: dotnet restore src/PDFtoImage.sln
- name: Publish
run: dotnet publish src/WebConverter/WebConverter.csproj -c Release -p:PublishProfile=src/WebConverter/Properties/PublishProfiles/PublishSite.pubxml --no-restore
- name: Create .nojekyll file
run: touch src/WebConverter/bin/Release/net7.0/publish/wwwroot/.nojekyll
- name: Update service-worker-assets.js hashes
working-directory: src/WebConverter/bin/Release/net7.0/publish/wwwroot
run: |
jsFile=$(<service-worker-assets.js)
# remove JavaScript from contents so it can be interpreted as JSON
json=$(echo "$jsFile" | sed "s/self.assetsManifest = //g" | sed "s/;//g")
# grab the assets JSON array
assets=$(echo "$json" | jq '.assets[]' -c)
for asset in $assets
do
oldHash=$(echo "$asset" | jq '.hash')
#remove leading and trailing quotes
oldHash="${oldHash:1:-1}"
path=$(echo "$asset" | jq '.url')
#remove leading and trailing quotes
path="${path:1:-1}"
newHash="sha256-$(openssl dgst -sha256 -binary $path | openssl base64 -A)"
if [ $oldHash != $newHash ]; then
# escape slashes for json
oldHash=$(echo "$oldHash" | sed 's;/;\\/;g')
newHash=$(echo "$newHash" | sed 's;/;\\/;g')
echo "Updating hash for $path from $oldHash to $newHash"
# escape slashes second time for sed
oldHash=$(echo "$oldHash" | sed 's;/;\\/;g')
jsFile=$(echo -n "$jsFile" | sed "s;$oldHash;$newHash;g")
fi
done
echo -n "$jsFile" > service-worker-assets.js
- name: Upload pages artifact
uses: actions/upload-pages-artifact@main
with:
Expand Down

0 comments on commit 1ff984f

Please sign in to comment.