-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #148 from OvertureMaps/automated-release-config
Add automated releases.json builder
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |