diff --git a/.github/workflows/update-cmdpriv-template.yml b/.github/workflows/update-cmdpriv-template.yml new file mode 100644 index 00000000..1dc617af --- /dev/null +++ b/.github/workflows/update-cmdpriv-template.yml @@ -0,0 +1,48 @@ +name: Update cmdpriv-template + +on: + push: + paths: + - 'pkg/qqbot/cmds/**' + pull_request: + types: [closed] + paths: + - 'pkg/qqbot/cmds/**' + +jobs: + update-cmdpriv-template: + if: github.event.pull_request.merged == true || github.event_name == 'push' + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Run generate_cmdpriv_template.py + run: python3 generate_cmdpriv_template.py + + - name: Check for changes in cmdpriv-template.json + id: check_changes + run: | + if git diff --name-only | grep -q "cmdpriv-template.json"; then + echo "::set-output name=changes_detected::true" + else + echo "::set-output name=changes_detected::false" + fi + + - name: Commit changes to cmdpriv-template.json + if: steps.check_changes.outputs.changes_detected == 'true' + run: | + git config --global user.name "GitHub Actions Bot" + git config --global user.email "" + git add cmdpriv-template.json + git commit -m "Update cmdpriv-template.json" + git push