|
1 | | -name: Update README (pull_request) |
| 1 | +name: README preview (PR) |
2 | 2 |
|
3 | 3 | on: |
4 | | - pull_request_target: |
| 4 | + pull_request: |
5 | 5 | paths: |
6 | 6 | - 'site/_data/summerschools.yml' |
7 | | - workflow_dispatch: |
8 | 7 |
|
9 | 8 | permissions: |
10 | | - pull-requests: write |
11 | 9 | contents: read |
12 | | - |
| 10 | + |
13 | 11 | jobs: |
14 | | - update-readme-pr: |
| 12 | + render-preview: |
15 | 13 | runs-on: ubuntu-latest |
16 | 14 | steps: |
17 | | - - name: Check out repository |
18 | | - uses: actions/checkout@v3 |
| 15 | + - uses: actions/checkout@v4 |
19 | 16 | with: |
20 | | - ref: ${{ github.event.pull_request.head.ref }} |
21 | | - repository: ${{ github.event.pull_request.head.repo.full_name }} |
22 | 17 | fetch-depth: 0 |
23 | | - |
24 | | - - name: Set up Python |
25 | | - uses: actions/setup-python@v4 |
| 18 | + |
| 19 | + - name: Fetch master |
| 20 | + run: git fetch origin master:master |
| 21 | + |
| 22 | + - uses: actions/setup-python@v5 |
26 | 23 | with: |
27 | | - python-version: '3.9' |
| 24 | + python-version: '3.11' |
28 | 25 |
|
29 | | - - name: Install dependencies |
30 | | - run: | |
31 | | - pip install pyyaml python-dateutil |
| 26 | + - run: pip install pyyaml python-dateutil ruamel.yaml |
32 | 27 |
|
33 | | - - name: Update README locally (no commit) |
34 | | - id: update_readme |
35 | | - run: | |
36 | | - python scripts/update_readme.py |
37 | | - git diff README.md > diff.txt |
| 28 | + - name: Render preview |
| 29 | + run: python scripts/pr_preview.py --output preview.md |
38 | 30 |
|
39 | | - # Expose the diff as an output |
40 | | - echo "diff<<EOF" >> $GITHUB_OUTPUT |
41 | | - cat diff.txt | sed 's/%/%25/g; s/\n/%0A/g; s/\r/%0D/g' >> $GITHUB_OUTPUT |
42 | | - echo "EOF" >> $GITHUB_OUTPUT |
| 31 | + - name: Save PR number |
| 32 | + run: echo "${{ github.event.pull_request.number }}" > pr-number.txt |
43 | 33 |
|
44 | | - - name: Comment on PR with diff |
45 | | - uses: actions/github-script@v6 |
| 34 | + - name: Upload artifact |
| 35 | + uses: actions/upload-artifact@v4 |
46 | 36 | with: |
47 | | - diff: ${{ steps.update_readme.outputs.diff }} |
48 | | - script: | |
49 | | - const diff = core.getInput('diff'); |
50 | | - if (!diff.trim()) { |
51 | | - core.info("No changes in README.md."); |
52 | | - return; |
53 | | - } |
54 | | - await github.rest.issues.createComment({ |
55 | | - owner: context.repo.owner, |
56 | | - repo: context.repo.repo, |
57 | | - issue_number: context.issue.number, |
58 | | - body: `**Proposed changes in README.md**\n\`\`\`diff\n${diff}\n\`\`\`` |
59 | | - }); |
60 | | - env: |
61 | | - diff: ${{ steps.update_readme.outputs.diff }} |
| 37 | + name: readme-preview |
| 38 | + path: | |
| 39 | + preview.md |
| 40 | + pr-number.txt |
0 commit comments