Upload to R2 #88
This file contains 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: Upload to R2 | |
on: | |
push: | |
branches: [ "main" ] | |
workflow_dispatch: | |
jobs: | |
Fetch: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
run: | | |
git clone --depth 1 https://github.com/neon-nyan/CollapseLauncher-ReleaseRepo.git cl-cdn | |
- name: Clean unused objects | |
run: | | |
rm -rf ./cl-cdn/.git | |
rm -rf ./cl-cdn/.github | |
rm -rf ./cl-cdn/actions | |
rm -rf ./cl-cdn/.gitignore | |
rm -rf ./cl-cdn/LICENSE | |
rm -rf ./cl-cdn/pack.bat | |
- name: Move folders around | |
run: | | |
mkdir -p ./cl-cdn/folderroot | |
mv ./cl-cdn/ApplyUpdate.exe ./cl-cdn/changelog_preview.md ./cl-cdn/changelog_stable.md ./cl-cdn/CollapseLauncher.Hi3CacheUpdater.cmd ./cl-cdn/folderroot/ | |
mv ./cl-cdn/notification_notepreview ./cl-cdn/notification_notestable ./cl-cdn/notification_preview.json ./cl-cdn/notification_stable.json ./cl-cdn/Update.exe ./cl-cdn/folderroot/ | |
mkdir -p ./cl-cdn/metadata/metadata-root | |
mv ./cl-cdn/metadata/metadatav2_previewconfig.json ./cl-cdn/metadata/metadatav2_previewstamp.json ./cl-cdn/metadata/metadata-root/ | |
mv ./cl-cdn/metadata/metadatav2_stableconfig.json ./cl-cdn/metadata/metadatav2_stablestamp.json ./cl-cdn/metadata/metadata-root/ | |
mkdir -p ./cl-cdn/metadata/metadata-images/game_logos | |
mkdir -p ./cl-cdn/metadata/metadata-images/game_posters | |
mv ./cl-cdn/metadata/game_logos/* ./cl-cdn/metadata/metadata-images/game_logos/ | |
mv ./cl-cdn/metadata/game_posters/* ./cl-cdn/metadata/metadata-images/game_posters/ | |
mkdir -p ./cl-cdn/applyupdate/stable | |
mkdir -p ./cl-cdn/applyupdate/preview | |
mv ./cl-cdn/preview ./cl-cdn/applyupdate/preview | |
mv ./cl-cdn/stable ./cl-cdn/applyupdate/stable | |
- name: Archive objects | |
run: | | |
zip -r root-cdn.zip ./cl-cdn/folderroot | |
zip -r root-metadata.zip ./cl-cdn/metadata/metadata-root | |
zip -r gameimages.zip ./cl-cdn/metadata/game_logos ./cl-cdn/metadata/game_posters | |
zip -r indexes_hi3.zip ./cl-cdn/metadata/repair_indexes/Hi3CN ./cl-cdn/metadata/repair_indexes/Hi3Global ./cl-cdn/metadata/repair_indexes/Hi3JP ./cl-cdn/metadata/repair_indexes/Hi3KR ./cl-cdn/metadata/repair_indexes/Hi3SEA ./cl-cdn/metadata/repair_indexes/Hi3TW | |
zip -r indexes_hsr.zip ./cl-cdn/metadata/repair_indexes/SRCN ./cl-cdn/metadata/repair_indexes/SRCNBilibili ./cl-cdn/metadata/repair_indexes/SRGlb | |
zip -r applyupdate.zip ./cl-cdn/applyupdate | |
zip -r squirrel-stable.zip ./cl-cdn/squirrel/stable | |
zip -r squirrel-preview.zip ./cl-cdn/squirrel/preview | |
- name: Upload root-cdn | |
uses: actions/upload-artifact@v3 | |
with: | |
name: root-cdn | |
path: root-cdn.zip | |
retention-days: 1 | |
- name: Upload root-metadata | |
uses: actions/upload-artifact@v3 | |
with: | |
name: root-metadata | |
path: root-metadata.zip | |
retention-days: 1 | |
- name: Upload root-metadata | |
uses: actions/upload-artifact@v3 | |
with: | |
name: gameimages | |
path: gameimages.zip | |
retention-days: 1 | |
- name: Upload indexes_hi3 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: indexes_hi3 | |
path: indexes_hi3.zip | |
retention-days: 1 | |
- name: Upload indexes_hsr | |
uses: actions/upload-artifact@v3 | |
with: | |
name: indexes_hsr | |
path: indexes_hsr.zip | |
retention-days: 1 | |
- name: Upload applyupdate | |
uses: actions/upload-artifact@v3 | |
with: | |
name: applyupdate | |
path: applyupdate.zip | |
retention-days: 1 | |
- name: Upload squirrel-stable | |
uses: actions/upload-artifact@v3 | |
with: | |
name: squirrel-stable | |
path: squirrel-stable.zip | |
retention-days: 1 | |
- name: Upload squirrel-preview | |
uses: actions/upload-artifact@v3 | |
with: | |
name: squirrel-preview | |
path: squirrel-preview.zip | |
retention-days: 1 | |
Sync-Root: | |
runs-on: ubuntu-latest | |
needs: Fetch | |
steps: | |
- name: Download Archive Artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: root-cdn | |
- name: Extract Archive | |
run: unzip -qq root-cdn/root-cdn.zip -d root-cdn | |
- name: Sync Root Folder | |
uses: ryand56/r2-upload-action@latest | |
with: | |
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} | |
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} | |
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
r2-bucket: ${{ secrets.R2_BUCKET }} | |
source-dir: root-cdn | |
destination-dir: cl-cdn | |
output-file-url: false | |
Sync-Metadata: | |
runs-on: ubuntu-latest | |
needs: Fetch | |
steps: | |
- name: Download Archive Artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: root-metadata | |
- name: Download Archive Artifact (gameimages) | |
uses: actions/download-artifact@v2 | |
with: | |
name: gameimages | |
- name: Extract Archive | |
run: | | |
unzip -qq root-metadata/root-metadata.zip -d root-metadata | |
unzip -qq gameimages/gameimages.zip -d root-metadata | |
- name: Sync Metadata root objects | |
uses: ryand56/r2-upload-action@latest | |
with: | |
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} | |
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} | |
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
r2-bucket: ${{ secrets.R2_BUCKET }} | |
source-dir: root-metadata | |
destination-dir: cl-cdn/metadata | |
output-file-url: false | |
Sync-Indexes-Hi3: | |
runs-on: ubuntu-latest | |
needs: Fetch | |
steps: | |
- name: Download Archive Artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: indexes_hi3 | |
- name: Extract Archive | |
run: | | |
unzip -qq indexes_hi3/indexes_hi3.zip -d indexes_hi3 | |
- name: Sync Metadata root objects | |
uses: ryand56/r2-upload-action@latest | |
with: | |
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} | |
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} | |
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
r2-bucket: ${{ secrets.R2_BUCKET }} | |
source-dir: indexes_hi3 | |
destination-dir: cl-cdn/metadata/repair_indexes | |
output-file-url: false | |
Sync-Indexes-HSR: | |
runs-on: ubuntu-latest | |
needs: Fetch | |
steps: | |
- name: Download Archive Artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: indexes_hsr | |
- name: Extract Archive | |
run: | | |
unzip -qq indexes_hsr/indexes_hsr.zip -d indexes_hsr | |
- name: Sync Metadata root objects | |
uses: ryand56/r2-upload-action@latest | |
with: | |
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} | |
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} | |
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
r2-bucket: ${{ secrets.R2_BUCKET }} | |
source-dir: indexes_hsr | |
destination-dir: cl-cdn/metadata/repair_indexes | |
output-file-url: false | |
Sync-ApplyUpdate: | |
runs-on: ubuntu-latest | |
needs: Fetch | |
steps: | |
- name: Download Archive Artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: applyupdate | |
- name: Extract Archive | |
run: unzip -qq applyupdate/applyupdate.zip -d applyupdate | |
- name: Sync ApplyUpdate | |
uses: ryand56/r2-upload-action@latest | |
with: | |
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} | |
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} | |
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
r2-bucket: ${{ secrets.R2_BUCKET }} | |
source-dir: applyupdate | |
destination-dir: cl-cdn | |
output-file-url: false | |
Sync-Squirrel-Stable: | |
runs-on: ubuntu-latest | |
needs: Fetch | |
steps: | |
- name: Download Archive Artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: squirrel-stable | |
- name: Extract Archive | |
run: unzip -qq squirrel-stable/squirrel-stable.zip -d squirrel-stable | |
- name: Sync Squirrel\Stable folder | |
uses: ryand56/r2-upload-action@latest | |
with: | |
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} | |
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} | |
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
r2-bucket: ${{ secrets.R2_BUCKET }} | |
source-dir: squirrel-stable | |
destination-dir: cl-cdn/squirrel/stable | |
output-file-url: false | |
Sync-Squirrel-Preview: | |
runs-on: ubuntu-latest | |
needs: Fetch | |
steps: | |
- name: Download Archive Artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: squirrel-preview | |
- name: Extract Archive | |
run: unzip -qq squirrel-preview/squirrel-preview.zip -d squirrel-preview | |
- name: Sync Squirrel\Stable folder | |
uses: ryand56/r2-upload-action@latest | |
with: | |
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} | |
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} | |
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
r2-bucket: ${{ secrets.R2_BUCKET }} | |
source-dir: squirrel-preview | |
destination-dir: cl-cdn/squirrel/preview | |
output-file-url: false | |
Purge-Cache: | |
runs-on: ubuntu-latest | |
if: always() # always purge cache whenever it fails or succeed | |
needs: [Sync-Root, Sync-Metadata, Sync-ApplyUpdate, Sync-Squirrel-Stable, Sync-Squirrel-Preview] | |
steps: | |
- name: Purge Cloudflare cache | |
run: | | |
curl -X POST "https://api.cloudflare.com/client/v4/zones/${{ secrets.CF_PURGE_CACHE_ZONEID }}/purge_cache" \ | |
-H "Authorization: Bearer ${{ secrets.CF_PURGE_CACHE_TOKEN }}" \ | |
-H "Content-Type: application/json" \ | |
--data "{ \"purge_everything\": true }" |