Skip to content

GetWeather

GetWeather #312

Workflow file for this run

# 除了北京时间的 00:01 和 12:01,剩下的每 2 小时执行一次 Hourly
# 每天北京时间的 00:01 和 12:01 执行一次 Daily
name: GetWeather
on:
schedule:
- cron: '1 2,4,6,8,10,14,16,18,20,22 * * *'
# What was your mission in Shanghai?!
timezone: "Asia/Shanghai"
- cron: '1 12,0 * * *'
# What was your mission in Shanghai?!
timezone: "Asia/Shanghai"
workflow_dispatch:
inputs:
run_daily:
description: Get Weather with Daily.
required: false
default: false
type: boolean
run_hourly:
description: Get Weather with Hourly.
required: false
default: true
type: boolean
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: What was your mission in Shanghai?!
uses: Sonic853/timezone-action@main
with:
timezoneLinux: 'Asia/Shanghai'
- name: Checkout repository
uses: actions/checkout@v6
- name: Checkout VRChat-World-Weather-Creator repository
uses: actions/checkout@v6
with:
repository: Sonic853/VRChat-World-Weather-Creator
path: VWWC
- name: Read updatetime.txt before running Deno
id: read_before_updatetime
run: echo "date=$(cat updatetime.txt)" >> $GITHUB_OUTPUT
- name: Install Deno
uses: denoland/setup-deno@v2
with:
cache: true
deno-version: latest
- name: Cache Deno dependencies
uses: actions/cache@v5
with:
path: |
~/.cache/deno
~/.deno
./pages
key: ${{ runner.os }}-deno-${{ hashFiles('**/deps.ts') }}
- name: Run Deno Cache
run: deno cache VWWC/create.ts
- name: Run Deno script (Daily)
if: ${{ github.event.schedule == '1 12,0 * * *' || github.event_name == 'workflow_dispatch' && inputs.run_daily }}
run: deno run --allow-read --allow-write --allow-net --allow-env VWWC/create.ts --mode=qwdaily,qwnow,qwhourly,accuwdaily --export=${{ secrets.EXPORT }} --accuweather=${{ secrets.ACCUWEATHER }} --qweather=${{ secrets.QWEATHER }} --free=${{ secrets.FREE }} --project=${{ secrets.PROJECT }} --key=${{ secrets.KEY }} --private=${{ secrets.PRIVATEKEY }} --apihost=${{ secrets.APIHOST }}
- name: Run Deno script (Hourly)
if: ${{ github.event.schedule == '1 2,4,6,8,10,14,16,18,20,22 * * *' || github.event_name == 'workflow_dispatch' && inputs.run_hourly }}
run: deno run --allow-read --allow-write --allow-net --allow-env VWWC/create.ts --mode=qwnow,qwhourly,accuwdaily --export=${{ secrets.EXPORT }} --saveurl=${{ secrets.SAVEURL }} --accuweather=${{ secrets.ACCUWEATHER }} --qweather=${{ secrets.QWEATHER }} --free=${{ secrets.FREE }} --project=${{ secrets.PROJECT }} --key=${{ secrets.KEY }} --private=${{ secrets.PRIVATEKEY }} --apihost=${{ secrets.APIHOST }}
- name: Read updatetime.txt after running Deno
id: read_after_updatetime
run: echo "date=$(cat updatetime.txt)" >> $GITHUB_OUTPUT
- name: Commit changes updatetime
if: steps.read_before_updatetime.outputs.date != steps.read_after_updatetime.outputs.date
run: |
git config --local user.email "Sonic853@qq.com" && git config --local user.name "853 Action"
git add updatetime.txt
git commit -m "Update updatetime.txt"
git push
- name: Setup Pages
uses: actions/configure-pages@v6
- name: Upload artifact
uses: actions/upload-pages-artifact@v5
with:
path: './pages'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
- name: Deploy to Server
uses: wlixcc/SFTP-Deploy-Action@v1.2.6
with:
username: '${{ secrets.SERVER_USER }}'
server: '${{ secrets.SERVER_IP }}'
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
password: ${{ secrets.SERVER_PASS }}
local_path: './pages/*'
remote_path: '${{ secrets.SERVER_REMOTE_PATH }}/${{ github.event.repository.name }}'
sftpArgs: '-o ConnectTimeout=5'
delete_remote_files: true