-
Notifications
You must be signed in to change notification settings - Fork 15
70 lines (63 loc) · 2.15 KB
/
Copy pathupdate-widget.yml
File metadata and controls
70 lines (63 loc) · 2.15 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
name: Update Discord Profile Widget
# Default scheduler switch (edit this line, no Settings needed):
# "true" -> run this GitHub Actions workflow
# "false" -> disable this workflow and use the Cloudflare Worker instead
env:
DEFAULT_ENABLED: "true"
on:
schedule:
- cron: '0 * * * *'
workflow_dispatch:
inputs:
force_run:
description: 'Force run even if disabled (DEFAULT_ENABLED=false or GH_ACTIONS_ENABLED=false)'
type: boolean
default: false
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Check if enabled
id: check
env:
GH_ACTIONS_ENABLED: ${{ vars.GH_ACTIONS_ENABLED }}
run: |
FORCE="${{ inputs.force_run }}"
VALUE="${GH_ACTIONS_ENABLED}" # repo variable, if set
if [ -z "$VALUE" ]; then
VALUE="${{ env.DEFAULT_ENABLED }}" # fallback to in-file default
fi
if [ "$FORCE" = "true" ]; then
VALUE="true"
fi
if [ "$VALUE" = "false" ]; then
ENABLED="false"
else
ENABLED="true"
fi
echo "enabled=$ENABLED" >> "$GITHUB_OUTPUT"
if [ "$ENABLED" = "true" ]; then
echo "GitHub Actions sync is enabled."
else
echo "GitHub Actions sync is disabled (DEFAULT_ENABLED=false). Skipping — use Cloudflare Worker instead."
fi
- name: Checkout code
if: steps.check.outputs.enabled == 'true'
uses: actions/checkout@v4
- name: Set up Node.js
if: steps.check.outputs.enabled == 'true'
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install dependencies
if: steps.check.outputs.enabled == 'true'
run: npm install
- name: Run sync script
if: steps.check.outputs.enabled == 'true'
run: npm start
env:
GH_USERNAME: ${{ secrets.GH_USERNAME }}
GH_PAT: ${{ secrets.GH_PAT }}
DISCORD_APPLICATION_ID: ${{ secrets.DISCORD_APPLICATION_ID }}
DISCORD_USER_ID: ${{ secrets.DISCORD_USER_ID }}
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}