Run Script and Commit Files #3650
This file contains hidden or 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: Run Script and Commit Files | |
| on: | |
| schedule: | |
| - cron: '*/30 * * * *' | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| run-script: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Cache pip dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('decrypt.py') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install cryptography beautifulsoup4 requests lxml | |
| - name: Run Python script | |
| env: | |
| PASSWORD: ${{ secrets.PASSWORD }} | |
| run: python decrypt.py | |
| - name: Check for changes | |
| id: verify-changed-files | |
| run: | | |
| if [ -n "$(git status --porcelain)" ]; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| echo "Files changed:" | |
| git status --porcelain | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| echo "No files changed" | |
| fi | |
| - name: Commit and push changes | |
| if: steps.verify-changed-files.outputs.changed == 'true' | |
| run: | | |
| git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add -A | |
| git commit -m "Automated update: $(date -u '+%Y-%m-%d %H:%M:%S UTC')" | |
| git push origin main | |
| - name: Output summary | |
| run: | | |
| if [ "${{ steps.verify-changed-files.outputs.changed }}" == "true" ]; then | |
| echo "✅ Changes committed and pushed successfully" | |
| else | |
| echo "ℹ️ No changes to commit" | |
| fi |