-
-
Notifications
You must be signed in to change notification settings - Fork 2
165 lines (148 loc) · 4.86 KB
/
Copy pathanalyze.yml
File metadata and controls
165 lines (148 loc) · 4.86 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
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Analyze
env:
TEST_PATTERN: '*justice.gov/*'
on:
pull_request: {}
schedule:
# Tuesday at 4pm UTC/9am PT
- cron: '40 16 * * 2'
workflow_dispatch:
inputs:
threshold:
description: 'Threshold'
required: false
type: string
pattern:
description: 'Pattern'
required: false
type: string
default: ''
tag:
description: 'Tag'
required: false
type: string
default: ''
from:
description: 'From Time'
required: false
type: string
default: ''
to:
description: 'To Time'
required: false
type: string
default: ''
readability:
description: 'Use Readability'
required: false
type: boolean
default: true
upload_folder:
description: 'Save to GDrive with this folder name'
required: false
type: string
default: ''
jobs:
analyze:
env:
DEFAULT_PATTERN: ${{ github.event_name == 'schedule' && '*' || '*justice.gov/*' }}
DEFAULT_THRESHOLD: '0.25'
DEFAULT_FROM: ${{ github.event_name == 'schedule' && '268' || '240' }}
DEFAULT_TO: '0'
USE_READABILITY: ${{ inputs.readability == false && 'false' || 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: '3.10'
cache: pip
- name: Install System Dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
gcc g++ pkg-config libxml2-dev libxslt-dev libz-dev
- name: Install Python Dependencies
run: pip install -r requirements.txt
- name: Download NLTK Corpora
run: |
python -m nltk.downloader stopwords
- uses: actions/setup-node@v5
if: env.USE_READABILITY == 'true'
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: readability-server/package-lock.json
- name: Install readability-server dependencies
if: env.USE_READABILITY == 'true'
run: |
cd readability-server
npm ci
- name: Run readability-server
if: env.USE_READABILITY == 'true'
run: |
cd readability-server
npm start &
- name: Analyze!
env:
WEB_MONITORING_DB_URL: '${{ secrets.WEB_MONITORING_DB_URL }}'
READABILITY_OPTIONS: ${{ env.USE_READABILITY == 'false' && '--skip-readability' || '' }}
TAG_OPTIONS: ${{ inputs.tag && format('--tag ''{0}''', inputs.tag) || '' }}
run: |
echo "Tag options: '${TAG_OPTIONS}'"
echo "Readability options: '${READABILITY_OPTIONS}'"
python generate_task_sheets.py \
--output out \
--after '${{ inputs.from || env.DEFAULT_FROM }}' \
--before '${{ inputs.to || env.DEFAULT_TO }}' \
--threshold '${{ inputs.threshold || env.DEFAULT_THRESHOLD }}' \
--pattern '${{ inputs.pattern || env.DEFAULT_PATTERN }}' \
${{ env.TAG_OPTIONS }} \
$READABILITY_OPTIONS
- name: Upload Results
uses: actions/upload-artifact@v4
with:
name: output
path: out
if-no-files-found: error
retention-days: 7
upload:
if: inputs.upload_folder || github.event_name == 'schedule'
needs:
- analyze
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v5
with:
name: output
path: out
- name: Install Rclone
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends rclone
- name: Configure Rclone
run: |
echo '${{ secrets.GOOGLE_DRIVE_SERVICE_ACCOUNT }}' | base64 --decode > gdrive-service-account.json
(
echo '[gdrive-task-sheets]'
echo 'type = drive'
echo 'scope = drive.file'
echo 'service_account_file = ./gdrive-service-account.json'
echo 'root_folder_id = ${{ secrets.GOOGLE_DRIVE_FOLDER_ID }}'
) > rclone.conf
- name: Upload
id: upload
run: |
FOLDER_NAME='${{ inputs.upload_folder }}'
if [ -z "${FOLDER_NAME}" ]; then
FOLDER_NAME="Scanner-sheets-$(date +'%Y-%m-%d')"
fi
rclone copy --config rclone.conf out "gdrive-task-sheets:${FOLDER_NAME}"
echo "folder_name=${FOLDER_NAME}" >> "$GITHUB_OUTPUT"
- name: Notify Slack
uses: slackapi/slack-github-action@v2.1.1
with:
webhook: ${{ secrets.SLACK_NOTIFICATION_WEBHOOK }}
webhook-type: incoming-webhook
payload: |
text: "<!here> This week’s sheets are now in the `${{ steps.upload.outputs.folder_name }}` folder in Google Drive."