Update fonts.zip #245
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Hashes | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| workflow_call: | |
| jobs: | |
| hash-files: | |
| if: ${{ github.repository_owner == 'WaspScripts' }} | |
| runs-on: windows-latest | |
| outputs: | |
| changes_detected: ${{ steps.check-changes.outputs.changed }} | |
| steps: | |
| - name: Fetch Simba 2 download URL | |
| id: simba-url | |
| run: | | |
| $url = "https://raw.githubusercontent.com/Villavu/Simba-Build-Archive/refs/heads/main/latest.win64" | |
| $response = Invoke-WebRequest -Uri $url -UseBasicParsing | |
| $baseUrl = $response.Content.Trim() -replace 'Win64\.zip\?raw=true$', '' | |
| Write-Output "Base URL: $baseUrl" | |
| echo "baseUrl=$baseUrl" >> $env:GITHUB_OUTPUT | |
| New-Item -Path ".\Includes" -ItemType Directory | |
| - name: Check Simba cache | |
| uses: actions/cache@v4 | |
| id: simba-cache | |
| with: | |
| path: ./Simba-Win64.exe | |
| key: simba-cache-${{ steps.simba-url.outputs.baseUrl }} | |
| enableCrossOsArchive: true | |
| - name: Download Simba 2.0 (64-bit) | |
| if: steps.simba-cache.outputs.cache-hit != 'true' | |
| run: | | |
| $baseUrl = "${{ steps.simba-url.outputs.baseUrl }}" | |
| $downloadUrl = "$baseUrl" + "Win64.zip?raw=true" | |
| $outputFile = ".\download.zip" | |
| Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile | |
| Expand-Archive -Path $outputFile -DestinationPath . -Force | |
| Remove-Item -Path $outputFile -Force | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| with: | |
| path: ./wasp-assets | |
| fetch-depth: 2 | |
| - name: Create hash files | |
| id: check-changes | |
| shell: bash | |
| run: | | |
| echo "Before: $(jq . ./wasp-assets/hashes.json)" | |
| ./Simba-Win64.exe --extractopenssl --run ./wasp-assets/tools/hash-files.simba | |
| echo "After: $(jq . ./wasp-assets/hashes.json)" | |
| cd ./wasp-assets | |
| if [[ -n "$(git status --porcelain hashes.json)" ]]; then | |
| echo "Changes detected in hashes.json" | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "No changes in hashes.json" | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit hashes.json | |
| if: steps.check-changes.outputs.changed == 'true' | |
| shell: bash | |
| run: | | |
| cd ./wasp-assets | |
| git config --global user.name "Wasp Bot" | |
| git config --global user.email "waspbot@waspscripts.com" | |
| git add hashes.json | |
| git commit -m "Automatic hash files update" | |
| git push | |
| - name: Upload files to Database | |
| if: steps.check-changes.outputs.changed == 'true' | |
| env: | |
| SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | |
| SUPABASE_KEY: ${{ secrets.SUPABASE_ANON_KEY }} | |
| shell: bash | |
| run: | | |
| cd ./wasp-assets | |
| while IFS= read -r file; do | |
| [ -z "$file" ] && continue | |
| if [ ! -f "$file" ]; then continue; fi | |
| remote_path="${file#./}" | |
| mime_type=$(file --mime-type -b "$file") | |
| curl -s -X PUT "$SUPABASE_URL/storage/v1/object/assets/$remote_path" \ | |
| -H "Authorization: Bearer $SUPABASE_KEY" \ | |
| -H "Content-Type: $mime_type" \ | |
| --data-binary @"$file" | |
| done < ./tools/whitelist.txt | |
| notification: | |
| if: ${{ github.repository_owner == 'WaspScripts' && github.ref == 'refs/heads/main' && needs.hash-files.outputs.changes_detected == 'true' }} | |
| runs-on: ubuntu-latest | |
| needs: hash-files | |
| steps: | |
| - name: Discord notification | |
| shell: bash | |
| run: | | |
| BODY=$(jq -nc \ | |
| --arg title "Assets Update" \ | |
| --arg desc "${{ github.event.head_commit.message }}" \ | |
| --arg url "https://github.com/WaspScripts/wasp-webapp/commit/${{ github.event.head_commit.id }}" \ | |
| --arg foot "Author: ${{ github.event.head_commit.author.name }}" \ | |
| --argjson color 16742912 \ | |
| '{embeds:[{title:$title,description:$desc,url:$url,color:$color,footer:{text:$foot}}]}') | |
| curl -H "Content-Type: application/json" -d "$BODY" ${{ secrets.UPDATES_WEBHOOK }} |