|
| 1 | +name: rustc-pull |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + # Run at 04:00 UTC every Monday |
| 7 | + - cron: '0 4 * * 1' |
| 8 | + |
| 9 | +jobs: |
| 10 | + pull: |
| 11 | + if: github.repository == 'rust-lang/rustc-dev-guide' |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + contents: write |
| 15 | + pull-requests: write |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + # We need the full history for josh to work |
| 20 | + fetch-depth: '0' |
| 21 | + - name: Install stable Rust toolchain |
| 22 | + run: rustup update stable |
| 23 | + - uses: Swatinem/rust-cache@v2 |
| 24 | + with: |
| 25 | + workspaces: "josh-sync" |
| 26 | + # Cache the josh directory with checked out rustc |
| 27 | + cache-directories: "/home/runner/.cache/rustc-dev-guide-josh" |
| 28 | + - name: Install josh |
| 29 | + run: RUSTFLAGS="--cap-lints warn" cargo +stable install josh-proxy --git https://github.com/josh-project/josh --tag r24.10.04 |
| 30 | + - name: Setup bot git name and email |
| 31 | + run: | |
| 32 | + git config --global user.name 'The rustc-dev-guide Cronjob Bot' |
| 33 | + git config --global user.email 'github-actions@github.com' |
| 34 | + - name: Perform rustc-pull |
| 35 | + run: cargo run --manifest-path josh-sync/Cargo.toml -- rustc-pull |
| 36 | + - name: Push changes to a branch |
| 37 | + run: | |
| 38 | + # Update a sticky branch that is used only for rustc pulls |
| 39 | + BRANCH="rustc-pull" |
| 40 | + git switch -c $BRANCH |
| 41 | + git push -u origin $BRANCH --force |
| 42 | + - name: Create pull request |
| 43 | + run: | |
| 44 | + # Check if an open pull request for an rustc pull update already exists |
| 45 | + # If it does, the previous push has just updated it |
| 46 | + # If not, we create it now |
| 47 | + RESULT=`gh pr list --author github-actions[bot] --state open -q 'map(select(.title=="Rustc pull update")) | length' --json title` |
| 48 | + if [[ "$RESULT" -eq 0 ]]; then |
| 49 | + echo "Creating new pull request" |
| 50 | + gh pr create -B master --title 'Rustc pull update' --body 'Latest update from rustc.' |
| 51 | + else |
| 52 | + echo "Updated existing pull request" |
| 53 | + fi |
| 54 | + env: |
| 55 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments