-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (73 loc) · 2.48 KB
/
post-bot.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
86
name: Rom Poster Bot
on:
push:
paths:
- "devices/*.json"
workflow_dispatch:
permissions: write-all
env:
GitHubMail: "[email protected]"
GitHubName: "ProjectZenithBot"
GitHubToken: ${{ secrets.GH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
CHAT_ID: ${{ secrets.CHAT_ID }}
PRIV_CHAT_ID: ${{ secrets.PRIV_CHAT_ID }}
ZENITH_VERSION_CHECK: ${{ secrets.ZENITH_VERSION_CHECK }}
jobs:
post:
runs-on: ubuntu-latest
steps:
# Check out the repository
- uses: actions/checkout@v3
# Install required Python dependencies
- name: Install Dependencies
run: |
python3 -m pip install --upgrade pip
pip3 install pyTelegramBotAPI noobstuffs PyGithub
# Configure Git credentials and settings
- name: Set Git Configs
run: |
git config --global user.email ${GitHubMail}
git config --global user.name ${GitHubName}
git config pull.rebase true
git config --global color.ui true
git config --global credential.helper store
echo "https://${{ env.GitHubName }}:${{ secrets.GH_TOKEN }}@github.com" > ~/.git-credentials
# Check and stash all changes (including untracked)
- name: Stash Changes Before Pull
run: |
echo "Checking for unstaged changes..."
git status
if [ -n "$(git status --porcelain)" ]; then
echo "Unstaged changes detected. Stashing changes..."
git stash --include-untracked
else
echo "No unstaged changes detected."
fi
# Pull latest changes from the repository
- name: Pull Latest Changes
run: |
echo "Pulling latest changes..."
git fetch --all
git pull --rebase
# Apply stashed changes (if applicable)
- name: Reapply Stashed Changes (if applicable)
run: |
if git stash list | grep -q "stash@{0}"; then
echo "Reapplying stashed changes..."
git stash pop
else
echo "No stashed changes to reapply."
fi
# Run the Python bot script
- name: Run RomPosterBot
run: |
python3 .github/scripts/post.py
# Commit and Push Changes
- name: Commit and Push Changes
run: |
COMMIT_MESSAGE="OTA: Update new IDs and push OTA [BOT]"
git add .
git commit -sm "$COMMIT_MESSAGE"
git push origin --force