-
Notifications
You must be signed in to change notification settings - Fork 73
54 lines (45 loc) · 1.5 KB
/
build-and-deploy.yml
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
name: Build and Deploy
on:
schedule:
- cron: '0 */6 * * *' # Runs every 6 hours
push:
branches:
- main
workflow_dispatch: # Allows manual trigger
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Set up SSH for Git (deploy key)
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan github.com >> ~/.ssh/known_hosts
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install Dependencies
run: |
python3 -m pip install --upgrade pip
pip install -r requirements.txt
- name: Fetch GitHub data
run: |
python3 gh-data.py
- name: Merge data sources
run: |
python3 merge-data.py
- name: Commit and Push Changes to `gh-pages`
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b gh-pages
git add -f merged-data.json
git add .
# If there are no changes, no commit gets created, and nothing is pushed
git commit -m "Update GitHub Pages with latest data"
git remote set-url origin [email protected]:${{ github.repository }}.git
git push origin gh-pages