DEV Community

okamos
okamos

Posted on

Simple Action: YAML Replacement

What I built

I build a GitHub Action called "YAML Replacement" that allows you yto replace specific values in a YAML file.

Category Submission:

Wacky Wildcards

App Link

Repository
Marketplace

Screenshots

N/A

Description

When you want to update a file cached in the browser, you change the URL of the file, like this:

<script src="production.min.js?ver=1"></script>
Enter fullscreen mode Exit fullscreen mode

to

<script src="production.min.js?ver=2"></script>
Enter fullscreen mode Exit fullscreen mode

The tails of url is often managed in YAML file. So when you deploy application, you need update the phrase 1 to 2. This action update the phrase to current date formatted YYYYMMDDhhmm.

The version number at the end of the URL is often managed in a YAML file. So, when you deploy your application, you need to update the version number from 1 to 2. This action updates the version number to the current date formatted as YYYYMMDDhhmm.

Link to Source Code

You can find the source code for the YAML Replacement action on GitHub: https://github.com/iisyos/yaml-replacement-action

Permissive License

This action is released under the MIT License.

Background (What made you decide to build this particular app? What inspired you?)

I decided to build GitHub Action because I often encountered scenarios where I needed to update the version number in a YAML file when deploying applications for updating browser cached files or just maintaining versions. Manually updating the version number was time-consuming and error-prone, so I wanted to automate this process to improve efficiency and accuracy.

How I built it (How did you utilize GitHub Actions or GitHub Codespaces? Did you learn something new along the way? Pick up a new skill?)

I built the YAML Replacement action using JavaScript and the GitHub Actions framework. The action takes inputs such as the path to the YAML file, the target key of the value to be replaced, and an optional flag indicating whether the changes should be pushed.

During the execution of the action, it reads the YAML file, identifies the target key, and replaces the corresponding value with the current date formatted as YYYYMMDDhhmm. If the "need-push" flag is set to true, the action commits and pushes the changes to the repository.

Along the way, I gained a deeper understanding of GitHub Actions, because it was my first time building actions😉.

Additional Resources/Info

N/A

Top comments (0)