generated from ottrproject/OTTR_Quarto
-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (128 loc) · 5.05 KB
/
pull_request.yml
File metadata and controls
152 lines (128 loc) · 5.05 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# Candace Savonen 2021
# Updated May 2025
name: Pull Request
on:
pull_request:
branches: [ main, staging ]
jobs:
yaml-check:
name: Load user automation choices
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Use the yaml-env-action action.
- name: Load environment from YAML
uses: doughepi/yaml-env-action@v1.0.0
with:
files: config_automation.yml # Pass a space-separated list of configuration files. Rightmost files take precedence.
# Delete the branch if this has been run before
- name: Delete branch locally and remotely
run: git push origin --delete preview-${{ github.event.pull_request.number }} || echo "No branch to delete"
# Make the branch fresh
- name: Make the branch fresh
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
branch_name='preview-${{ github.event.pull_request.number }}'
echo branch doesnt exist
git checkout -b $branch_name || echo branch exists
git push --set-upstream origin $branch_name || echo branch exists remotely
shell: bash
outputs:
toggle_website: "${{ env.RENDER_WEBSITE }}"
toggle_spell_check: "${{ env.SPELL_CHECK }}"
spell_error_min: "${{ env.SPELL_ERROR_MIN }}"
toggle_style_code: "${{ env.STYLE_CODE }}"
toggle_url_check: "${{ env.URL_CHECKER }}"
url_error_min: "${{ env.URL_ERROR_MIN }}"
toggle_quiz_check: "${{ env.CHECK_QUIZZES }}"
quiz_error_min: "${{ env.QUIZ_ERROR_MIN }}"
toggle_md_linter: "${{ env.MARKDOWN_LINTER }}"
toggle_readability: "${{ env.READABILITY_REPORT }}"
toggle_render_preview: "${{ env.RENDER_PREVIEW }}"
toggle_dictionary_sort: "${{ env.DICTIONARY_SORT }}"
rendering_docker_image: "${{ env.RENDERING_DOCKER_IMAGE }}"
########################## Make the error reports ##############################
ottr-reports:
name: Run Reports
needs: yaml-check
if: ${{needs.yaml-check.outputs.toggle_spell_check == 'true' || needs.yaml-check.outputs.toggle_url_check == 'true' || needs.yaml-check.outputs.toggle_quiz_check == 'true'}}
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run Reports
id: run-reports
uses: ottrproject/ottr-reports@main
with:
check_spelling: ${{needs.yaml-check.outputs.toggle_spell_check}}
spelling_error_min: ${{needs.yaml-check.outputs.spell_error_min}}
check_urls: ${{needs.yaml-check.outputs.toggle_url_check}}
url_error_min: ${{needs.yaml-check.outputs.url_error_min}}
check_quiz_form: ${{needs.yaml-check.outputs.toggle_spell_check}}
quiz_error_min: ${{needs.yaml-check.outputs.quiz_error_min}}
sort_dictionary: ${{needs.yaml-check.outputs.toggle_dictionary_sort}}
############################# Style the code ###################################
style-code:
name: Style code
needs: yaml-check
runs-on: ubuntu-latest
if: ${{needs.yaml-check.outputs.toggle_style_code == 'true'}}
container:
image: jhudsl/base_ottr:main
steps:
- name: Checkout files
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run styler
run: Rscript -e "styler::style_file(list.files(pattern = '(R|q)md$', recursive = FALSE, full.names = TRUE));warnings()"
- name: Commit styled files
run: |
git config --system --add safe.directory "$GITHUB_WORKSPACE"
git add \*md
git commit -m 'Style *mds' || echo "No changes to commit"
git push origin || echo "No changes to commit"
############################# Readability Report ###################################
readability-report:
name: Readability report
needs: yaml-check
runs-on: ubuntu-latest
if: ${{needs.yaml-check.outputs.toggle_readability == 'true'}}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Readability report
uses: Rebilly/lexi@v2
with:
github-token: ${{ secrets.GH_PAT }}
glob: '**/*.md'
############################# Render Preview ###################################
render-preview:
name: Render preview
needs: yaml-check
runs-on: ubuntu-latest
if: ${{needs.yaml-check.outputs.toggle_render_preview == 'true'}}
permissions:
pull-requests: write
contents: write
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run render
uses: ottrproject/ottr-preview@main
with:
toggle_website: ${{needs.yaml-check.outputs.toggle_website}}
docker_image: ${{needs.yaml-check.outputs.rendering_docker_image}}