-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (51 loc) · 1.8 KB
/
job.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
55
56
57
58
59
60
name: Update and Deploy
on:
repository_dispatch:
workflow_dispatch:
schedule:
- cron: "*/5 * * * *" # Runs every 5 minutes
# push:
# branches:
# - main
jobs:
update-and-deploy:
runs-on: ubuntu-22.04
steps:
# Step 1: Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3
# Step 2: Set up the environment (install necessary tools if needed)
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y curl netcat iputils-ping
# Step 3: Save current index.html to archive
- name: Archive old index
run: |
# Ensure the script is executable
chmod +x archive.sh
./archive.sh
# Step 4: Run the script to update index.html
- name: Run script and update index.html
run: |
# Ensure the script is executable
chmod +x generate-html.sh
# Run the script to generate index.html
./generate-html.sh > index.html
# Step 5: Commit and push changes to the repository
- name: Commit and push updated files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git add index.html
git add archive/*
git commit -m "Update index.html and archive with latest script output" || echo "No changes to commit"
git push
# Step 6: Deploy to GitHub Pages
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: main # Branch to deploy from (main)
folder: . # Folder to deploy (root directory)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}