forked from protomaps/PMTiles
-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (64 loc) · 2.72 KB
/
test.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
name: Update protomaps tiles on Cloudflare R2
on:
schedule:
- cron: '15 14 1 */2 *'
workflow_dispatch:
jobs:
update-tiles:
runs-on: ubuntu-latest
steps:
- name: Set AWS credentials
env:
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
run: |
echo "Setting AWS Credentials"
aws configure set aws_access_key_id "$R2_ACCESS_KEY_ID"
aws configure set aws_secret_access_key "$R2_SECRET_ACCESS_KEY"
- name: Download latest tileset
run: |
TODAY="$(date +'%Y%m%d')"
echo "TODAY=$TODAY" >> $GITHUB_ENV
echo "Today's date for filename is $TODAY"
echo "Downloading protomaps pmtiles file."
# wget https://build.protomaps.com/"${TODAY}".pmtiles
echo "test" > 20231112.pmtiles
- name: Upload tileset to Cloudflare R2
env:
R2_API_ENDPOINT: ${{ secrets.R2_API_ENDPOINT }}
run: |
aws s3api list-objects-v2 --bucket protomaps --endpoint-url https://"$R2_API_ENDPOINT".r2.cloudflarestorage.com > output.json
OLD_MAP_TILES=$(jq -r '.Contents[0].Key')
echo "OLD_MAP_TILES=$OLD_MAP_TILES" >> $GITHUB_ENV
echo "Uploading file to Cloudflare R2"
aws s3 cp "${{ env.TODAY }}".pmtiles s3://protomaps/"${{ env.TODAY }}"/world.pmtiles --endpoint-url https://"$R2_API_ENDPOINT".r2.cloudflarestorage.com
- name: Checkout repo
uses: actions/checkout@v4
with:
sparse-checkout: |
js
serverless/cloudflare
sparse-checkout-cone-mode: false
- name: Update PMTILES_PATH environment variable in wrangler.toml
run: |
PMTILES_PATH="${{ env.TODAY }}/{name}.pmtiles"
sed -i -E 's|PMTILES_PATH =.*|PMTILES_PATH = "'"$PMTILES_PATH"'"|g' serverless/cloudflare/wrangler.toml
- name: Build & Deploy Worker
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_WORKERS_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
preCommands: |
cd js
npm install
cd ../serverless/cloudflare
npm install
- name: Push updated wrangler.toml to repo
uses: test-room-7/action-update-file@v1
with:
file-path: serverless/cloudflare/wrangler.toml
commit-msg: Update wrangler.toml to latest version
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Delete old map tiles file from Cloudflare R2
run: |
aws s3 rm s3://protomaps/"${{ env.OLD_MAP_FILE }}" --endpoint-url https://"$R2_API_ENDPOINT".r2.cloudflarestorage.com