52 lines
1.6 KiB
YAML
52 lines
1.6 KiB
YAML
name: Template Cleanup
|
|
on:
|
|
# create:
|
|
# push:
|
|
# branches: [ main ]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
|
|
# 当前仓库名不为 zabbix-agent2-plugin-template 时触发
|
|
template-cleanup:
|
|
name: Template Cleanup
|
|
runs-on: ubuntu-latest
|
|
if: github.event.repository.name != 'zabbix-agent2-plugin-template'
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
|
|
- name: Fetch Sources
|
|
uses: actions/checkout@v4
|
|
|
|
# 项目清理
|
|
- name: Cleanup
|
|
run: |
|
|
export LC_CTYPE=C
|
|
export LANG=C
|
|
|
|
# 准备变量
|
|
OWNER=$(echo $GITHUB_REPOSITORY_OWNER | tr '[:upper:]' '[:lower:]')
|
|
REPO_NAME="${GITHUB_REPOSITORY##*/}"
|
|
SAFE_OWNER=$(echo $OWNER | sed 's/[^a-zA-Z0-9]//g' | tr '[:upper:]' '[:lower:]')
|
|
SAFE_REPO_NAME=$(echo $REPO_NAME | sed 's/[^a-zA-Z0-9]//g' | tr '[:upper:]' '[:lower:]')
|
|
PLUGIN_NAME=$(echo "$SAFE_REPO_NAME" | sed 's/^\(.\)/\U\1/')
|
|
|
|
# 替换包名
|
|
find . -type f -exec sed -i "s/zabbixagent2plugintemplate/$SAFE_REPO_NAME/g" {} +
|
|
find . -type f -exec sed -i "s/Zabbixagent2plugintemplate/$PLUGIN_NAME/g" {} +
|
|
find . -type f -exec sed -i "s/Zabbix Agent 2 Plugin Template/$REPO_NAME/g" {} +
|
|
|
|
- name: Commit files
|
|
run: |
|
|
git config --local user.email "action@github.com"
|
|
git config --local user.name "GitHub Action"
|
|
git add .
|
|
git commit -m "Template cleanup"
|
|
|
|
- name: Push changes
|
|
uses: ad-m/github-push-action@master
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
branch: ${{ github.ref }}
|