Update IP-1.js #15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sync ISP Function | |
on: | |
push: | |
paths: | |
- 'Module/Panel/IP-info/Moore/IP-1.js' | |
workflow_dispatch: # 允许手动触发 | |
jobs: | |
sync-function: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' # 安装Node.js 20 | |
- name: Sync ISP function to other files | |
env: | |
NODE_VERSION: 20 | |
run: | | |
# Ensure the correct Node.js version is active | |
nvm install $NODE_VERSION | |
nvm use $NODE_VERSION | |
# Define the file paths | |
SOURCE_FILE="Module/Panel/IP-info/Moore/IP-1.js" | |
TARGET_FILES=("Module/Panel/IP-info/Moore/IP-2.js" "Module/Panel/IP-info/Moore/IP-3.js" "Module/Panel/IP-info/Moore/IP-4.js") | |
# Extract the cleanIspInfo function from the source file and save to a temporary file | |
awk '/function cleanIspInfo/,/^}/' $SOURCE_FILE > /tmp/cleanIspInfo.js | |
# Iterate over the target files and replace the cleanIspInfo function | |
for TARGET_FILE in "${TARGET_FILES[@]}"; do | |
# Remove the existing cleanIspInfo function in the target file | |
sed -i '/function cleanIspInfo/,/^}/d' $TARGET_FILE | |
# Append the new cleanIspInfo function to the target file | |
cat /tmp/cleanIspInfo.js >> $TARGET_FILE | |
done | |
# Check if there are any changes | |
if [ -n "$(git status --porcelain)" ]; then | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add . | |
git commit -m "Sync cleanIspInfo function from IP-1.js to IP-2.js, IP-3.js, IP-4.js" | |
git push | |
else | |
echo "No changes detected" | |
fi |