-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (128 loc) · 4.73 KB
/
publish-website.yml
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
on:
push:
branches: [master]
schedule:
- cron: '30 4 * * *'
- cron: '30 19 * * *'
release:
types: [published]
workflow_dispatch:
name: buildvespaPiemonte
jobs:
build-website:
runs-on: ubuntu-latest
env:
# GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
QFIELD_CLOUD_PASSWORD: ${{ secrets.QFIELD_CLOUD_PASSWORD }}
QFIELD_CLOUD_USERNAME: ${{ secrets.QFIELD_CLOUD_USERNAME }}
QFIELD_CLOUD_PROJECTNAME: ${{ secrets.QFIELD_CLOUD_PROJECTNAME }}
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
permissions:
contents: write
steps:
- name: "Check out repository"
uses: actions/checkout@v4
- name: Install dependencies on Linux
if: runner.os == 'Linux'
run: sudo apt-get update -y && sudo apt-get install -y libproj-dev libgdal-dev libgeos-dev libudunits2-dev language-pack-it
- name: "Setup R"
uses: r-lib/actions/setup-r@v2
- name: Install R Dependencies
uses: r-lib/actions/setup-renv@v2
- name: Ensure cache directory exists
run: mkdir -p cache
- name: Ensure cache/pubdata directory exists
run: mkdir -p cache/pubdata
- name: Check if today is Sunday
id: check-sunday
run: |
day_of_week=$(date +%u)
if [ "$day_of_week" -eq 7 ]; then
echo "is_sunday=true" >> $GITHUB_ENV
else
echo "is_sunday=false" >> $GITHUB_ENV
fi
- name: Cache built data
id: cache-data-all
uses: actions/cache@v2
with:
path: cache
key: build-data-${{ hashFiles('cache/**/*') }}
restore-keys: |
build-data-
- name: Cache data
id: cache-data
uses: actions/cache@v2
with:
path: cache
key: shapefile-${{ runner.os }}-${{ env.is_sunday }}
restore-keys: |
shapefile-
- name: Download shapefile if needed
if: env.is_sunday == 'true'
run: |
curl -L -o cache/pubdata/AMBITI_AMMINISTRATIVI_COMUNI1.zip "https://www.datigeo-piem-download.it/direct/Geoportale/RegionePiemonte/Limiti_amministrativi/AMBITI_AMMINISTRATIVI_COMUNI1.zip"
echo "Downloaded new file"
#
# - name: Check if cache was hit
# id: check-cache
# run: |
# if [ -f "cache/pubdata/AMBITI_AMMINISTRATIVI_COMUNI1.zip" ]; then
# local_hash=$(md5sum cache/pubdata/AMBITI_AMMINISTRATIVI_COMUNI1.zip | awk '{print $1}')
# echo "local_hash=$local_hash"
# echo "local_hash=$local_hash" >> $GITHUB_ENV
# if [ "$local_hash" = "$remote_hash" ]; then
# echo "Cache hit, file is up to date"
# echo "cache_hit=true" >> $GITHUB_ENV
# else
# echo "Cache miss, file is outdated"
# echo "cache_hit=false" >> $GITHUB_ENV
# fi
# else
# echo "Cache miss, file does not exist"
# echo "cache_hit=false" >> $GITHUB_ENV
# fi
#
# - name: Debug cache hit
# run: echo "cache_hit=$cache_hit"
#
# - name: Download shapefile if needed
# if: env.cache_hit != 'true'
# run: |
# curl -L -o cache/pubdata/AMBITI_AMMINISTRATIVI_COMUNI1.zip "https://www.datigeo-piem-download.it/direct/Geoportale/RegionePiemonte/Limiti_amministrativi/AMBITI_AMMINISTRATIVI_COMUNI1.zip"
# echo "Downloaded new file"
#
- name: Cache downloaded file
uses: actions/cache@v2
with:
path: cache/pubdata/AMBITI_AMMINISTRATIVI_COMUNI1.zip
key: shapefile-${{ env.remote_hash }}
restore-keys: |
shapefile-
- name: Check if cache was hit
run: |
if [ -f "cache/nidi.rds" ] && [ -f "cache/trap.rds" ]; then
echo "Cache hit, data files exist"
else
echo "Cache miss, data files do not exist"
fi
- name: Check and update geographical data
run: |
Rscript scripts/start_script_v2.R
- name: Cache updated data
uses: actions/cache@v2
with:
path: cache
key: build-data-${{ hashFiles('cache/**/*') }}
# - name: Other calculations
# run: Rscript -e 'source("scripts/complete_script_v2.R")'
- name: "Set up Quarto"
uses: quarto-dev/quarto-actions/setup@v2
- name: "Render and Publish"
uses: quarto-dev/quarto-actions/publish@v2
with:
target: gh-pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}