GitHub Action
YAML Replacement
YAML Replacement
YAML Replacement
Replace specific value in YAML file
Installation
Copy and paste the following snippet into your .yml file.
- name: YAML Replacement
uses: iisyos/yaml-replacement-action@v1
YAML Replacement action
This action replace specific value in YAML file.
Motivation & 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>to
<script src="production.min.js?ver=2"></script>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.
Inputs
yaml-file-path
Required The path to your YAML file that needs the replacement.
target-key
Required The key of the value that needs to be replaced in the YAML file.
need-push
If you need to push these changes, set true, default false
Notice You need to supply your Personal Access Token (PAT) which allows repository access to the checkout action. For example:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
token: ${{ secrets.MY_PERSONAL_ACCESS_TOKEN }}Example usage
uses: iisyos/yaml-replacement-action@v1
with:
yaml-file-path: 'setting.yaml'
target-key: 'step.revision'
need-push: trueIn the above example, the setting.yaml file should be in the following format:
step:
revision: '202301011200' # <- replace