-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (98 loc) · 3.23 KB
/
Copy pathcollector-job.yml
File metadata and controls
102 lines (98 loc) · 3.23 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
name: Collector Job
on:
# schedule:
# - cron: '0 10 * * *'
workflow_dispatch:
inputs:
collectForced:
description: 'Flag to force collection regardless the configuration'
type: boolean
default: false
required: true
category:
description: 'News Category to filter out'
type: string
required: true
default: '*'
environment:
description: 'Environment to run tests against'
type: environment
required: false
workflow_call:
inputs:
collectForced:
description: 'Flag to force collection regardless the configuration'
type: boolean
default: false
required: true
category:
description: 'News Category to filter out'
type: string
required: true
default: '*'
outputs:
status_code:
description: "Status Code from Climateline API"
value: ${{jobs.dispatcher.outputs.status_code}}
jobs:
dispatcher:
runs-on: ubuntu-latest
outputs:
status_code: ${{ steps.dispatcher.outputs.status_code }}
steps:
- name: Fetch new articles (dispatcher)
id: dispatcher
run: |
CODE=`curl --write-out '%{http_code}' \
--silent \
--output /dev/null \
--request GET \
--header 'Authorization: Bearer ${{ secrets.CLIMATELINE_JOB_SECRET }}' \
--header 'content-type: application/json' \
--url "https://climateline-processor.vercel.app/api/collector-job?category=$CATEGORY&collect_forced=$PUBLISH_FORCED"`
echo "status_code=$CODE" >> $GITHUB_OUTPUT
if: ${{ github.event_name != 'schedule' }}
env:
COLLECT_FORCED: ${{ inputs.collectForced }}
CATEGORY: ${{ inputs.category }}
# checker-success:
# runs-on: ubuntu-latest
# needs: dispatcher
# steps:
# - run: echo success
# if: ${{ needs.dispatcher.outputs.status_code == '200' }}
# env:
# COLLECT_FORCED: ${{ inputs.collectForced }}
# CATEGORY: ${{ inputs.category }}
# STATUS: ${{ needs.dispatcher.outputs.status_code }}
#
# checker-no-content:
# runs-on: ubuntu-latest
# needs: dispatcher
# steps:
# - run: echo no-content
# if: ${{ needs.dispatcher.outputs.status_code == '204' }}
# env:
# COLLECT_FORCED: ${{ inputs.collectForced }}
# CATEGORY: ${{ inputs.category }}
# STATUS: ${{ needs.dispatcher.outputs.status_code }}
schedule:
runs-on: ubuntu-latest
steps:
- name: Fetch new articles (schedule)
run: |
CODE=`curl --write-out '%{http_code}' \
--silent \
--output /dev/null \
--request GET \
--header 'Authorization: Bearer ${{ secrets.CLIMATELINE_JOB_SECRET }}' \
--header 'content-type: application/json' \
--url "https://climateline-processor.vercel.app/api/collector-job?category=$CATEGORY&collect_forced=$COLLECT_FORCED"`
if [ $CODE != "200" ]; then
exit 1
fi
# if: ${{ github.event_name == 'schedule' }}
if: github.event.schedule == '0 22 * * *'
env:
COLLECT_FORCED: false
CATEGORY: climate