-
Notifications
You must be signed in to change notification settings - Fork 3
85 lines (70 loc) · 2.61 KB
/
main.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Checks
on:
push:
branches:
- '**'
workflow_dispatch:
jobs:
format_repo:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }} # Make sure PR is checked out
- name: Install Prettier
run: npm install prettier
- name: Install required modules
run: python -m pip install clrprint markdown beautifulsoup4 ujson
- name: Run pre_commit.py
run: python pys/pre_commit.py --format
- name: Commit changes
run: |
git config --global user.name "NSPBot911"
git config --global user.email ${{ secrets.BOT_EMAIL }}
git add -A
if git diff-index --quiet HEAD --; then
echo "No changes to commit"
else
git commit -m "[actions] Post Commit Checks Completed" -m "$(git log -1 --pretty=format:'%an') forgot to run pre_commit.py --format" -m "skip-checks: true"
git push
fi
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
deploy_page:
needs: format_repo
if: github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'skip-deploy')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Replace server IP in JavaScript
run: |
sed -i 's|const serverip = "localhost";|const serverip = "${{ secrets.IP_FOR_SERVER }}";|g' webUI/app.js
- name: Deploy to GitHub Pages
uses: crazy-max/ghaction-github-pages@v4
with:
target_branch: gh-pages
build_dir: ./webUI
author: NSPBot911 <${{ secrets.BOT_EMAIL }}>
committer: NSPBot911 <${{ secrets.BOT_EMAIL }}>
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
update_server:
needs: deploy_page
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'skip-update')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get latest commit title
id: get_commit
run: |
echo "commit_title=$(git log -1 --pretty=%s)" >> $GITHUB_ENV
- name: Trigger server-backend workflow
run: |
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.BOT_TOKEN }}" \
https://api.github.com/repos/BEComTweaks/server-backend/actions/workflows/106751072/dispatches \
-d "{\"ref\":\"main\", \"inputs\":{\"title\":\"resource-packs: ${{ env.commit_title }}\"}}"