-
Notifications
You must be signed in to change notification settings - Fork 3
113 lines (103 loc) · 4.14 KB
/
hash-files.yml
File metadata and controls
113 lines (103 loc) · 4.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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 }}