@@ -20,25 +20,43 @@ jobs:
20
20
- name : Build docker image
21
21
run : docker build -t gradient-pipeline ./pipeline
22
22
23
- - name : Run the pipeline
23
+ - name : set date
24
+ id : set_date
24
25
run : |
25
26
current_date=$(date +%Y-%m-%d)
27
+ echo "CURRENT_DATE=$current_date" >> $GITHUB_OUTPUT
28
+
29
+ - name : set hour minus two
30
+ id : set_hour
31
+ run : |
26
32
current_hour=$(date +%H)
27
33
hour_minus_two=$((current_hour - 2))
28
- if [ $hour_minus_two -lt 0 ]; then
29
- current_date=$(date -d "-1 day" +%Y-%m-%d)
30
- hour_minus_two=$((current_hour + 22))
31
- fi
32
- docker run -it -v ./data:/tmp gradient-pipeline sh -c "node cli.js process-hour $current_date $hour_minus_two"
33
- if [ $? -eq 0 ]; then
34
- # Add a leading zero if the hour is less than 10
35
- [[ $hour_minus_two -lt 10 && $hour_minus_two -ge 0 ]] && hour_minus_two="0$hour_minus_two"
36
- file_name="${current_date}T${hour_minus_two}"
37
- docker run -it -v ./data:/tmp gradient-pipeline sh -c "ogr2ogr -f FlatGeobuf /tmp/${file_name}.fgb /tmp/${file_name}.geojson -skipfailures"
38
- else
39
- echo "Previous command failed"
40
- exit 1
34
+ echo "CURRENT_HOUR=$current_hour" >> $GITHUB_OUTPUT
35
+ echo "HOUR_MINUS_TWO=$hour_minus_two" >> $GITHUB_OUTPUT
36
+
37
+ - name : process changesets
38
+ run : |
39
+ docker run -v ./data:/tmp gradient-pipeline sh -c "node cli.js process-hour $CURRENT_DATE $HOUR_MINUS_TWO"
40
+ env :
41
+ CURRENT_DATE : ${{ steps.set_date.outputs.CURRENT_DATE }}
42
+ HOUR_MINUS_TWO : ${{ steps.set_hour.outputs.HOUR_MINUS_TWO }}
43
+
44
+ - name : padded hour
45
+ id : padded_hour
46
+ run : |
47
+ if [[ $HOUR_MINUS_TWO -lt 10 && $HOUR_MINUS_TWO -gt 0 ]]; then
48
+ HOUR_MINUS_TWO="0$HOUR_MINUS_TWO"
41
49
fi
50
+ echo "PADDED_HOUR=$HOUR_MINUS_TWO" >> $GITHUB_OUTPUT
51
+ env :
52
+ HOUR_MINUS_TWO : ${{ steps.set_hour.outputs.HOUR_MINUS_TWO }}
53
+
54
+ - name : convert to fgb
55
+ run : |
56
+ docker run -v ./data:/tmp gradient-pipeline sh -c "ogr2ogr -f FlatGeobuf /tmp/${CURRENT_DATE}T${PADDED_HOUR}.fgb /tmp/${CURRENT_DATE}T${PADDED_HOUR}.geojson -skipfailures"
57
+ env :
58
+ CURRENT_DATE : ${{ steps.set_date.outputs.CURRENT_DATE }}
59
+ PADDED_HOUR : ${{ steps.padded_hour.outputs.PADDED_HOUR }}
42
60
43
61
- name : Check if the pipeline ran successfully
44
62
run : ls -lh ./data
0 commit comments