Daily Package Sync Checker #12
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: "Daily Package Sync Checker" | |
| on: | |
| schedule: | |
| - cron: "0 0 * * *" # Run daily at midnight UTC | |
| issues: | |
| types: [labeled] | |
| workflow_dispatch: # Allow manual triggering | |
| permissions: | |
| contents: write # This gives the workflow permission to push to the repository | |
| jobs: | |
| check-packages: | |
| runs-on: ubuntu-latest | |
| # Skip if this is triggered by a label that's not 'package-broken' or 'package-missing' | |
| if: ${{ github.event_name != 'issues' || contains(github.event.label.name, 'package-broken') || contains(github.event.label.name, 'package-missing') }} | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 # Fetch all history for proper commit messages | |
| token: ${{ secrets.GH_PAT }} # Use PAT for checkout to ensure push access | |
| - name: Debug Git setup | |
| run: | | |
| echo "Current user: $(git config user.name)" | |
| echo "Current email: $(git config user.email)" | |
| echo "Remote URL: $(git remote -v)" | |
| echo "Current branch: $(git branch --show-current)" | |
| echo "GitHub Actor: ${{ github.actor }}" | |
| echo "GitHub Repository: ${{ github.repository }}" | |
| echo "Trigger event: ${{ github.event_name }}" | |
| if [[ "${{ github.event_name }}" == "issues" ]]; then | |
| echo "Issue number: ${{ github.event.issue.number }}" | |
| echo "Issue title: ${{ github.event.issue.title }}" | |
| echo "Label: ${{ github.event.label.name }}" | |
| fi | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.x" | |
| - name: Install dependencies | |
| run: | | |
| pip install requests toml | |
| - name: Run daily check script | |
| run: | | |
| python scripts/daily_check.py | |
| env: | |
| GH_PAT: ${{ secrets.GH_PAT }} | |
| - name: Comment on issue if triggered by label | |
| if: ${{ github.event_name == 'issues' }} | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ secrets.GH_PAT }} | |
| script: | | |
| github.rest.issues.createComment({ | |
| issue_number: context.payload.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: 'Package validity check has been run based on this issue label. The registry has been updated if any changes were detected.' | |
| }) |