Rename to #407
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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/**/*.yaml) | |
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") | |
providers=() | |
domains=() | |
values=() | |
# Loop through the found files and extract the 'provider' and 'domain' fields | |
for file in $cfg_files; do | |
provider=$(yq eval '.provider' "$file" 2>/dev/null || echo "tekton") | |
domain=$(yq eval '.domain' "$file" 2>/dev/null || echo "demo") | |
# If either field is missing, set default values | |
provider=${provider:-"unknown_provider"} | |
domain=${domain:-"unknown_domain"} | |
# Create the key as type:domain | |
key="$provider:$domain" | |
# Check if the key already exists in the arrays | |
found=0 | |
for i in "${!providers[@]}"; do | |
if [[ "${providers[$i]}" == "$provider" && "${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 | |
providers+=("$provider") | |
domains+=("$domain") | |
values+=("$file") | |
fi | |
done | |
# Print the markdown headers and grouped files, grouping by type | |
last_provider="" | |
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 "${!providers[@]}"; do | |
provider="${providers[$i]}" | |
domain="${domains[$i]}" | |
# Print the type header only if it's different from the last printed type | |
if [[ "$provider" != "$last_type" ]]; then | |
printf '%s\n\n' "## $provider" >> SCENARIO.md | |
last_provider="$provider" | |
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") | |
resourceProvider=$(cat "$f" | yq -r ".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/$provider/$domain/$(echo $resourceProvider | 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. |