Skip to content

Commit

Permalink
added compiled_release workflow
Browse files Browse the repository at this point in the history
This workflow creates a release with one compiled flight segment file
for all flights.
  • Loading branch information
d70-t committed Aug 11, 2020
1 parent 2fb1747 commit 96b9fff
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/compiled_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

name: Upload Release Asset

jobs:
build:
name: Upload Release Asset
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r scripts/requirements.txt
- name: Compile all flight segment files into one yaml file
run: |
cd scripts
python compile.py ../flight_phase_files/*/*.yaml -o ../all_flights.yaml
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./all_flights.yaml
asset_name: all_flights.yaml
asset_content_type: text/yaml
31 changes: 31 additions & 0 deletions scripts/compile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import sys
import yaml
from collections import defaultdict

def _main():
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("infiles", type=str, nargs="+")
parser.add_argument("-o", "--outfile", type=str)

args = parser.parse_args()

all_flights = defaultdict(dict)

for filename in args.infiles:
with open(filename) as f:
flight = yaml.load(f, Loader=yaml.SafeLoader)
all_flights[flight["platform"]][flight["flight_id"]] = flight

if args.outfile:
outfile = open(args.outfile, "w")
else:
outfile = sys.stdout

yaml.dump(dict(all_flights.items()), outfile)

return 0

if __name__ == "__main__":
exit(_main())
2 changes: 2 additions & 0 deletions scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# for reading the files
pyyaml

0 comments on commit 96b9fff

Please sign in to comment.