Skip to content

Update README with New Content #26

Update README with New Content

Update README with New Content #26

name: Update README with New Content
on:
workflow_dispatch:
push:
schedule:
# Runs at 00:00 UTC every Sunday
- cron: '0 0 * * 0'
jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Clone Second Repository
run: git clone https://github.com/localstack/docs.git
- name: Gather Tutorials and Videos
run: |
cd docs/content/en/tutorials/
tutorials_section="### Tutorials \n\n"
for folder in */; do
folder_name=${folder%/}
title=$(grep '^title:' "$folder/index.md" | sed 's/title: //')
tutorials_section+="- [$title](https://docs.localstack.cloud/tutorials/$folder_name)\n"
done
cd ../academy/
for folder in */; do
academy_section+="#### $(grep '^title:' "$folder/_index.md" | sed 's/title: //')\n\n"
if [ -d "$folder" ]; then
for subfolder in "$folder"*/; do
title=$(grep '^title:' "$subfolder/index.md" | sed 's/title: //')
url=$(grep '^url:' "$subfolder/index.md" | sed 's/url: "\(.*\)"/\1/')
academy_section+="- [$title](https://docs.localstack.cloud/$url)\n"
done
fi
done
cd ../../../../
sed -i '/## Content/,$d' README.md
echo "## Content" >> README.md
echo "" >> README.md
echo "### Tutorials" >> README.md
echo "### Videos" >> README.md
awk -v tutorials="$tutorials_section" -v academy="$academy_section" '
/^## Content/ {print; next}
/^### Tutorials/ { print tutorials; next}
/^### Videos/ {print; print academy; next;}
1' README.md > temp.md && mv temp.md README.md
- name: Clone Second Repository
run: git clone https://github.com/localstack/localstack-blog.github.io.git
- name: Gather Blog Posts
run: |
cd localstack-blog.github.io/content/
blog_section="### Blog Posts \n\n"
for folder in */; do
folder_name=${folder%/}
title=$(grep '^title:' "$folder/index.md" | sed 's/title: //')
blog_section+="- [$title](https://blog.localstack.cloud/$folder_name)\n"
done
cd ../..
echo "### Blog Posts" >> README.md
awk -v blogs="$blog_section" '
/^### Blog Posts/ {print blogs; next;}
1' README.md > temp.md && mv temp.md README.md
- name: Commit and Push Changes
run: |
git config --global user.name 'AncaGhenade'
git config --global user.email '[email protected]'
git add README.md
git diff --quiet && git diff --staged --quiet || (git add README.md && git commit -m "Update README with new tutorials, videos and blog posts" && git push)