Skip to content

Fetch and Convert YAML to JSON #151

Fetch and Convert YAML to JSON

Fetch and Convert YAML to JSON #151

name: Fetch and Convert YAML to JSON
on:
schedule:
- cron: '5 * * * *'
#- cron: '0 0 1 * *' # Runs at midnight UTC on the first day of each month
workflow_dispatch: # Trigger manually or on push
push:
branches:
- main
jobs:
convert-yaml-to-json:
runs-on: ubuntu-latest
steps:
# Checkout the repo with write permissions
- name: Checkout repository
uses: actions/checkout@v2
with:
persist-credentials: true # Keeps GitHub token for push
# Install yq by downloading the binary
- name: Install yq
run: |
YQ_VERSION=v4.30.8 # Check latest version on https://github.com/mikefarah/yq/releases
wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -O /usr/local/bin/yq
chmod +x /usr/local/bin/yq
# Fetch YAML file from URL
- name: Download YAML file
run: |
curl -L https://raw.githubusercontent.com/AdobeDocs/commerce-operations.en/main/_jekyll/_data/system-requirements.yml -o file.yaml
# Convert YAML to JSON
- name: Convert YAML to JSON
run: |
yq eval -j file.yaml > file.json
# Commit and push the JSON file back to the repo
- name: Commit and push JSON file
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add *
git commit -m "Add JSON file generated from YAML"
git push