Call Worktree Update #25
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: Update Worktree and Trigger Workflow | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| schedule: | |
| - cron: '0 20 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| trigger: | |
| runs-on: ubuntu-latest | |
| permissions: write-all | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Download and run collect_worktree_info.py | |
| run: | | |
| # Download the script | |
| curl -o collect_worktree_info.py https://raw.githubusercontent.com/HITSZ-OpenAuto/repos-management/main/scripts/collect_worktree_info.py | |
| # Make it executable and run it | |
| chmod +x collect_worktree_info.py | |
| python3 collect_worktree_info.py | |
| # Clean up the downloaded script | |
| rm collect_worktree_info.py | |
| - name: Commit worktree info changes | |
| run: | | |
| # Configure git | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Actions" | |
| # Add changes if any exist | |
| if [ -n "$(git status --porcelain)" ]; then | |
| git add .hoa/worktree.json | |
| git commit -m "Update worktree [skip ci]" | |
| git push origin main | |
| echo "Worktree updated and committed to main branch" | |
| else | |
| echo "No changes to commit" | |
| fi | |
| - name: Trigger workflow in hoa-moe | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
| run: | | |
| curl -X POST \ | |
| -H "Accept: application/vnd.github.v3+json" \ | |
| -H "Authorization: token $GITHUB_TOKEN" \ | |
| https://api.github.com/repos/HITSZ-OpenAuto/hoa-moe/actions/workflows/course.yaml/dispatches \ | |
| -d '{"ref":"main"}' |