-
Notifications
You must be signed in to change notification settings - Fork 1
87 lines (68 loc) · 2.93 KB
/
update-content.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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 'LocalStack Bot'
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)