Skip to content

Commit

Permalink
Merge pull request #148 from OvertureMaps/automated-release-config
Browse files Browse the repository at this point in the history
Add automated releases.json builder
  • Loading branch information
jenningsanderson authored Apr 25, 2024
2 parents 25b6064 + 0252404 commit 4a4aa3b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/fetch-releases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Fetch releases from S3

on:
push:
branches: main
schedule:
- cron: "0 1 * * *"

workflow_dispatch:

permissions:
contents: read
id-token: write

jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install boto3
- name: Get all history from checkfront
run: cd utils && python3 fetch-releases-from-s3.py

- name: copy_output_to_build
run: mkdir publish && cp utils/releases.json publish/

- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: publish
19 changes: 19 additions & 0 deletions utils/fetch-releases-from-s3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import boto3, json
from botocore import UNSIGNED
from botocore.config import Config

s3 = boto3.client('s3', config=Config(signature_version=UNSIGNED))

contents = s3.list_objects_v2(Bucket='overturemaps-us-west-2', Delimiter='/', Prefix='release/')

output = {}

for idx, release in enumerate(sorted(contents.get('CommonPrefixes'), key=lambda x:x.get('Prefix'), reverse = True)):
path = release.get('Prefix').split('/')[1]
if idx==0:
output['latest'] = path
output['releases'] = []
output['releases'].append(path)

with open ('releases.json','w') as output_file:
output_file.write(json.dumps(output, indent=4))

0 comments on commit 4a4aa3b

Please sign in to comment.