Repository navigation
66 lines (58 loc) · 2.14 KB
/
Copy pathdeploy.yml
File metadata and controls
66 lines (58 loc) · 2.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
name: Deploy Product
on:
push:
branches: ["main"]
schedule:
- cron: '0 12 * * 0' # Weekly on Sunday at 12:00 UTC
workflow_dispatch:
permissions:
contents: write
pages: write # Optional: Remove if not using GitHub Pages
id-token: write # Optional: Remove if not using GitHub Pages
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Update data
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
run: node scripts/api-call.js
env:
RAPIDAPI_KEY: ${{ secrets.RAPIDAPI_KEY }}
- name: Commit changes
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add data/events.json
if ! git diff --staged --quiet; then
if [ "${{ github.event_name }}" = "schedule" ]; then
git commit -m "Scheduled update - $(date -u '+%Y-%m-%d %H:%M')"
else
git commit -m "Manual update - $(date -u '+%Y-%m-%d %H:%M')"
fi
git push
fi
# Optional: Deploy to GitHub Pages (uncomment if building a website)
# - name: Setup Pages
# uses: actions/configure-pages@v5
# - name: Upload Pages
# uses: actions/upload-pages-artifact@v3
# with:
# path: '.'
# - name: Deploy to Pages
# id: deployment
# uses: actions/deploy-pages@v4
# Optional: Post to Twitter (uncomment if building a social media bot)
# Add TWITTER_BEARER_TOKEN to repository secrets
# - name: Post to Twitter
# if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
# run: node scripts/post-twitter.js
# env:
# TWITTER_BEARER_TOKEN: ${{ secrets.TWITTER_BEARER_TOKEN }}