Skip to content

Commit

Permalink
Replace[tungbq#94]: Generate Content steps with shell script
Browse files Browse the repository at this point in the history
  • Loading branch information
vivekvr1 committed Oct 25, 2023
1 parent 4c9fb8a commit aff009a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 35 deletions.
36 changes: 1 addition & 35 deletions .github/workflows/generate-content.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,7 @@ jobs:
run: sudo apt-get install jq -y

- name: Generate Content
run: |
json=$(cat services.json)
services=$(echo "$json" | jq -r '.services[] | @base64')
echo "Clean up the previous content under 'Service introduction'"
sed -i '/# Service introduction/,$ {/# Service introduction/!d}' README.md
for service in $services; do
_jq() {
echo ${service} | base64 --decode | jq -r ${1}
}
folder=$(_jq '.service_folder_name')
url=$(_jq '.service_url')
youtube_url=$(_jq '.service_youtube_url')
service_name=$(_jq '.service_name')
if [ ! -d "$folder" ]; then
mkdir "$folder"
echo "Folder created: $folder"
else
echo "Folder already exists: $folder"
fi
echo "# $service_name" > "$folder/README.md"
# Update the service README.md content
echo -e "- Official AWS URL: $url" >> "$folder/README.md"
echo -e "- Official YouTube Introduction: $youtube_url" >> "$folder/README.md"
echo "Check the new content in $folder/README.md"
cat "$folder/README.md"
# Update the README.md content
echo -e "- [$folder/README.md](./$folder/README.md)" >> README.md
done
echo "Check the new content in README.md"
cat README.md
run: sh generate-content.sh

- name: Commit changes
run: |
Expand Down
36 changes: 36 additions & 0 deletions generate-content.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

json=$(cat services.json)
services=$(echo "$json" | jq -r '.services[] | @base64')

echo "Clean up the previous content under 'Service introduction'"
sed -i '/# Service introduction/,$ {/# Service introduction/!d}' README.md

for service in $services; do
_jq() {
echo ${service} | base64 --decode | jq -r ${1}
}
folder=$(_jq '.service_folder_name')
url=$(_jq '.service_url')
youtube_url=$(_jq '.service_youtube_url')
service_name=$(_jq '.service_name')

if [ ! -d "$folder" ]; then
mkdir "$folder"
echo "Folder created: $folder"
else
echo "Folder already exists: $folder"
fi

echo "# $service_name" > "$folder/README.md"
# Update the service README.md content
echo -e "- Official AWS URL: $url" >> "$folder/README.md"
echo -e "- Official YouTube Introduction: $youtube_url" >> "$folder/README.md"
echo "Check the new content in $folder/README.md"
cat "$folder/README.md"

# Update the README.md content
echo -e "- [$folder/README.md](./$folder/README.md)" >> README.md
done
echo "Check the new content in README.md"
cat README.md

0 comments on commit aff009a

Please sign in to comment.