summaryrefslogtreecommitdiffstats
path: root/src/doc/rustc-dev-guide/.github/workflows/date-check.yml
blob: bf2a7a81923ac8f017df70626d1ba1282e1ede76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: Date-Check

on:
  schedule:
    # Run at noon UTC every 1st of the month
    - cron: '00 12 01 * *'

  # Allow manually starting the workflow
  workflow_dispatch:

jobs:
  date-check:
    if: github.repository == 'rust-lang/rustc-dev-guide'
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repo
        uses: actions/checkout@v3

      - name: Ensure Rust is up-to-date
        run: |
          rustup update stable

      - name: Run `date-check`
        working-directory: ci/date-check
        run: |
          cargo run -- ../../src/ > ../../date-check-output.txt

      - name: Open issue
        uses: actions/github-script@v6
        with:
          script: |
            const fs = require('fs');

            const rawText = fs.readFileSync('date-check-output.txt', { encoding: 'utf8' });
            const title = rawText.split('\n')[0];
            if (title != 'empty') {
                const body = rawText.split('\n').slice(1).join('\n');
                github.rest.issues.create({
                  owner: context.repo.owner,
                  repo: context.repo.repo,
                  title,
                  body,
                });
                console.log('Opened issue.');
            } else {
                console.log('No dates to triage.');
            }