Skip to content

Keep enable SPLIT_LINES #328

Keep enable SPLIT_LINES

Keep enable SPLIT_LINES #328

# Publish Pipelines generated when project is tagged
name: Publish Pipelines generated
on:
workflow_dispatch:
push:
branches:
- main
jobs:
generate:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: maven
- name: Build with Maven
run: mvn -B clean package
- name: Run the builder application over the existing configurations
run: |
# Cleanup the generated folder
rm -rf generated/**/*
cfg_files=(configurations/**/*)
for f in "${cfg_files[@]}"
do
java -jar target/quarkus-app/quarkus-run.jar builder -o generated -c $f
done
# NOT USED ANYMORE
# Sometimes the python script happens ``` end of the last YAML line and remove the next README CR
#
#- name: Markdown Code Embed
# continue-on-error: true
# #if: steps.changed-files-yaml.outputs.doc_any_changed == 'true'
# run: |
# #!/usr/bin/env bash
# set -e
#
# git clone https://github.com/ippie52/markdown_code_embed.git
#
# python markdown_code_embed/mdce.py -f README.md
# NOT USED
#- name: Get doc files that have changed
# id: changed-files-yaml
# uses: tj-actions/changed-files@v44
# with:
# files_yaml: |
# doc:
# - '**.md'
- name: Generate the content of the SCENARIO.md file
run: |
CMD="java -jar target/quarkus-app/quarkus-run.jar builder"
cfg_files=$(find configurations -type f -name "*.yaml" -o -name "*.yml")
types=()
domains=()
values=()
# Loop through the found files and extract the 'type' and 'domain' fields
for file in $cfg_files; do
type=$(yq eval '.type' "$file" 2>/dev/null || echo "tekton")
domain=$(yq eval '.domain' "$file" 2>/dev/null || echo "demo")
# If either field is missing, set default values
type=${type:-"unknown_type"}
domain=${domain:-"unknown_domain"}
# Create the key as type:domain
key="$type:$domain"
# Check if the key already exists in the arrays
found=0
for i in "${!types[@]}"; do
if [[ "${types[$i]}" == "$type" && "${domains[$i]}" == "$domain" ]]; then
# Append the file to the corresponding value
values[$i]="${values[$i]} $file"
found=1
break
fi
done
# If the key was not found, add a new entry
if [[ $found -eq 0 ]]; then
types+=("$type")
domains+=("$domain")
values+=("$file")
fi
done
# Print the markdown headers and grouped files, grouping by type
last_type=""
printf '%s\n\n' "# Scenario" > SCENARIO.md
printf '%s\n' "This document is generated by the job \'.github/workflows/publish-pipelines.yml\' using the [configurations](configurations/) files !" >> SCENARIO.md
for i in "${!types[@]}"; do
type="${types[$i]}"
domain="${domains[$i]}"
# Print the type header only if it's different from the last printed type
if [[ "$type" != "$last_type" ]]; then
printf '%s\n\n' "## $type" >> SCENARIO.md
last_type="$type"
fi
# Print the domain as a subheader
printf '%s\n\n' "### ${domain^}" >> SCENARIO.md
# Print the files under this type and domain
for f in ${values[$i]}; do
title=$(cat "$f" | yq -r ".job.description")
fileName=$(cat "$f" | yq -r ".job.name")
resourceType=$(cat "$f" | yq -r ".job.resourceType" || echo "PipelineRun")
printf '%s\n\n' "#### ${title^}" >> SCENARIO.md
printf '%s\n' "Command to be executed: " >> SCENARIO.md
printf '%s\n' "\`\`\`bash" >> SCENARIO.md
printf '%s\n' "$CMD -o out/flows -c $f" >> SCENARIO.md
printf '%s\n' "\`\`\`" >> SCENARIO.md
printf '%s\n' "using as configuration: " >> SCENARIO.md
printf '%s\n' "\`\`\`yaml" >> SCENARIO.md
printf '%s\n' "# $f" >> SCENARIO.md
printf '%s\n' "\`\`\`" >> SCENARIO.md
printf '%s\n' "Generated file: " >> SCENARIO.md
printf '%s\n' "\`\`\`yaml" >> SCENARIO.md
generate_path="generated/$type/$domain/$(echo $resourceType | awk '{print tolower($0)}')-$fileName.yaml"
printf '%s\n' "# $generate_path" >> SCENARIO.md
printf '%s\n' "\`\`\`" >> SCENARIO.md
done
done
- name: Embed snippet code within the SCENARIO.md file
run: |
npx embedme SCENARIO.md
- name: Get current date
id: date
#if: steps.changed-files-yaml.outputs.doc_any_changed == 'true'
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Create pull request for the updated SCENARIO.md file
#if: steps.changed-files-yaml.outputs.doc_any_changed == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: new-generated-pipelines-${{ env.CURRENT_DATE }}
title: "New resources generated and SCENARIO.md file updated - ${{ env.CURRENT_DATE }}"
labels: |
documentation
body: |
Pull request for New resources generated and SCENARIO.md changed.