Skip to content

Update latest.json

Update latest.json #8

name: Update latest.json
on:
workflow_dispatch:
schedule:
- cron: "0 16 * * *"
permissions:
contents: write
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set variables
run: echo "RELEASE_NAME=Released on $(date +%Y%m%d%H%M)" >> $GITHUB_ENV
shell: bash
- name: Make directory
run: mkdir publish
- name: Generate latest.json file
run: |
wget https://api.github.com/repos/${{ github.repository }}/releases/latest -O publish/latest.json
wget https://api.github.com/repos/moesnow/Fhoe-Rail/releases/latest -O publish/fight-latest.json
wget https://api.github.com/repos/CHNZYX/Auto_Simulated_Universe/releases/latest -O publish/universe-latest.json
- name: Git push assets to "release" branch
run: |
cd publish || exit 1
git init
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -b release
git add .
git commit -m "${{ env.RELEASE_NAME }}"
git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}"
git push -f -u origin release
- name: Purge jsdelivr CDN
run: |
cd publish || exit 1
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@release/latest.json"
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@release/fight-latest.json"
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@release/universe-latest.json"