diff --git a/.github/rss_2_yaml.py b/.github/rss_2_yaml.py new file mode 100644 index 0000000..bb5465e --- /dev/null +++ b/.github/rss_2_yaml.py @@ -0,0 +1,36 @@ +from argparse import ArgumentParser +import hashlib +from pathlib import Path + +import feedparser +import yaml + +def grab_funding(output_dir="_data/"): + """ + Queries CURIOSS RSS feed and creates a yaml file for jekyll to consume. + + Jekyll expect the data files under the `_data` directory. + """ + output_dir = Path(output_dir) + h = hashlib.new('sha256') + feed = feedparser.parse("https://curioss.org/resources/funding-opportunities/index.xml") + + output_dict = dict() + + for entry in feed['entries']: + h.update(entry['title'].encode()) + output_dict[h.hexdigest()] = { + 'title': entry['title'], + 'url': entry['link'], + 'description': entry['description'].replace('$', '\\$'), + } + + with open(output_dir/'funding.yaml', 'w') as f: + yaml.dump(output_dict, stream=f) + +if __name__ == '__main__': + parser = ArgumentParser(description="Grab and generates a yaml file for Jekyll") + parser.add_argument('--outdir', '-o', default='_data', + help='The directory where to save the file') + arguments= parser.parse_args() + grab_funding(output_dir=arguments.outdir) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 048f9b5..a10aed6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,8 @@ on: push: branches: ["main"] pull_request: + schedule: + - cron: "27 0 * * 1,4" permissions: contents: read @@ -16,6 +18,13 @@ jobs: steps: - name: Checkout uses: actions/checkout@v6 + - name: Set Python + uses: actions/setup-python@v6 + with: + python-version: '3.13' + - run: pip install pyyaml feedparser + - name: Update funding opportunities + run: python .github/rss_2_yaml.py - name: Build uses: actions/jekyll-build-pages@v1 # The next step uploads a "special" artifact used by the diff --git a/_includes/funding.html b/_includes/funding.html new file mode 100644 index 0000000..9f934ca --- /dev/null +++ b/_includes/funding.html @@ -0,0 +1,8 @@ +{% assign details = funding_op[1] %} + +