Using Github Actions to Convert File Formats

Adam DJ Brett June 12, 2024
Source

This post is all about learning and coding in public. We learn from each others mistakes and we get better by building together.

One of my favorite longterm projects has been RELCFP. It is a simple site that aggregate religious studies call for papers. The site works by pulling in a custom RSS Feed and CFPs that have been submitted via the site. I like to blend the data together so that people can quickly and easily get to the main location of these call for papers. Recently the script I have been using broke. is no longer recommended as a way to display and style XML. Here is the broken script 🪦.

I am working on several ways to replace this script. First I replaced my old FreshRSS server with a wonderful Eleventy starter theme called Multiplicity-M10ty by @lwojcik. Now instead of a bland RSS feed and yet another server bill I have a nicely stylized feed with clear attributions. Plus this new site is much easier to upate.

Now for part 2 fixing the homepage of relcfp.com. I want and need an automated and easy way to style the data. I am able to easily import the RSS. Now I just need to style it. Styling the XML is proving rather difficult. One of the solutions I am exploring is convering the XML into JSON and styling JSON something which is a much clearer and more well documented process. Using CI/CD I want to create a Github Action that will automatically convert XML to JSON and then commit the new JSON file to the repository.

I found a really cool github action "Data Format Converter Action" by @fabasoad. Through lots of trial and error and kind assistance by fabasoad. I wwas able to get the Github Action almost working on my repository. Presently my issue is that the script runs but it does not output and add a new results.json to the repository.

Setting up "Data Format Converter Github Action" by @fabasoad Here is what I have learned for how to setup this Github Action.

Current Instructions The current instructions are rather threadbare but thanks to the assistance of @fabasoad I was able to get them working.

Option 1: Personal access token (PAT)

  1. Create PAT with repo permission.
  2. Create repository secret (e.g. MY_GITHUB_TOKEN) with the PAT value.
  3. Use the following configuration:

My comments In this section please make sure that you create your ``MY_GITHUB_TOKENPersonal access tokens (classic)yaml

  • uses: actions/create-github-app-token@v1 id: generate-app-token with: app-id: ${{ vars.APP_ID }} private-key: ${{ secrets.APP_PRIVATE_KEY }}
  • uses: fabasoad/data-format-converter-action@v0 with: input: "person.xml" from: "xml" to: "yaml" token: ${{ steps.generate-app-token.outputs.token }} and this key will download to your computer. You are going to copy and paste that whole key into the that you create on your repository. Likewise you will want to use the APP_ID and not the Client_ID as your vairable.

Setting up the App I had a lot of issues trying to figure out the keys. If you are having trouble, I do recomend walks to give your brain a break and to reset. I did not take enough breaks and that actually, ironically slowed me down and made this whole process take way longer.

Current Settings

Presently I am stuck on what do I do next, how do I output the demo data to a json file and commit that file to my repository? After I commit the file to my repository, then I can move over to trying to do this with a full RSS XML feed and see how well that works.

In order to get the "Configure Git" step to work I followed this article: "How to solve "Permission to x denied to github-actions[bot]"".

Following that article I was able to get my file to save and commit to the repository.

What wound up working was two things first sanitzing the json thanks to @spenserblack

Second switching to python thanks to @imajeetyadav

The current full file may be viewed in the repo

Thank you to:

  • @fabasoad on github
  • Mahboob Ahmed on Stack Overflow
  • Raule Melo
  • @imajeetyadav
  • @spenserblack

Thank you to all of them for being willing to learn, create, and help in public.

Now to apply this to my main repo. relcfp.com

Update Everything is working great now. Please go check out the site relcfp.com

Discussion in the ATmosphere

Loading comments...