{
"$type": "site.standard.document",
"canonicalUrl": "https://www.adamdjbrett.com/blog/2024-06-12-using-github-actions-convert-file-formats/",
"path": "/blog/2024-06-12-using-github-actions-convert-file-formats/",
"publishedAt": "2024-06-12T12:00:00.000Z",
"site": "at://did:plc:3vmq5usrh3yvhbrrzf4ymo23/site.standard.publication/3mpfboadoa72e",
"tags": "website",
"textContent": "This post is all about learning and coding in public. We learn from each others mistakes and we get better by building together.\n\n *\n\nOne 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 🪦.\n\nI 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.\n\nNow 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.\n\nI 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. \n\nSetting up \"Data Format Converter Github Action\" by @fabasoad\nHere is what I have learned for how to setup this Github Action.\n\nCurrent Instructions\nThe current instructions are rather threadbare but thanks to the assistance of @fabasoad I was able to get them working. \n\n>\n>\n>Option 1: Personal access token (PAT)\n>\n>1. Create PAT\n> with repo permission.\n>2. Create repository secret\n> (e.g. MY_GITHUB_TOKEN) with the PAT value.\n>3. Use the following configuration:\n>\n>\n>\n\nMy comments\nIn this section please make sure that you create your ``MY_GITHUB_TOKENPersonal access tokens (classic)yaml\n>- uses: actions/create-github-app-token@v1\n >id: generate-app-token\n >with:\n >app-id: ${{ vars.APP_ID }}\n >private-key: ${{ secrets.APP_PRIVATE_KEY }}\n>- uses: fabasoad/data-format-converter-action@v0\n >with:\n >input: \"person.xml\"\n >from: \"xml\"\n >to: \"yaml\"\n >token: ${{ steps.generate-app-token.outputs.token }}\n> 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. \n\nSetting up the App\nI 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.\n\nCurrent Settings\n\nPresently 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.\n\nIn order to get the \"Configure Git\" step to work I followed this article: [\"How to solve \"Permission to x denied to github-actions[bot]\"\"](https://www.raulmelo.me/en/til/how-to-solve-permission-to-x-denied-to-github-actions-bot).\n\nFollowing that article I was able to get my file to save and commit to the repository.\n\nWhat wound up working was two things first sanitzing the json thanks to @spenserblack\n\nSecond switching to python thanks to @imajeetyadav\n\nThe current full file may be viewed in the repo\n\nThank you to:\n- @fabasoad on github\n- Mahboob Ahmed on Stack Overflow\n- Raule Melo\n- @imajeetyadav\n- @spenserblack\n\nThank you to all of them for being willing to learn, create, and help in public.\n\nNow to apply this to my main repo. relcfp.com\n\nUpdate\nEverything is working great now. Please go check out the site relcfp.com",
"title": "Using Github Actions to Convert File Formats"
}