@@ -17,3 +17,43 @@ export -f slugify
1717
1818git config user.name github-actions
1919git config user.email github-actions@github.com
20+
21+ update_deployments_list () {
22+ github_project_url=$( git remote get-url origin)
23+ if [[ $github_project_url == git@github.com:* ]]; then
24+ github_repo=$( echo ${github_project_url# " git@github.com:" } | sed ' s/\.git$//g' )
25+ elif [[ $github_project_url == https://github.com/* ]]; then
26+ github_repo=$( echo ${github_project_url# " https://github.com/" } | sed ' s/\.git$//g' | sed ' s/^\/\///g' )
27+ fi
28+
29+ github_repo_owner=$( echo " ${github_repo} " | sed ' s/\/.*$//g' )
30+ github_repo_name=$( echo " ${github_repo} " | sed ' s/^.*\///g' )
31+
32+ deployments_list=" DEPLOYMENTS.md"
33+ echo " Updating ${deployments_list} "
34+ rm $deployments_list
35+
36+ # Create a markdown table
37+ touch $deployments_list
38+ echo " # Deployments" >> $deployments_list
39+ echo " " >> $deployments_list
40+ echo " | Branch | Link |" >> $deployments_list
41+ echo " | --- | --- |" >> $deployments_list
42+
43+ main_deployment_url=" https://${github_repo_owner} .github.io/${github_repo_name} /"
44+ echo " | [${main_git_branch} ](https://github.com/${github_repo_owner} /${github_repo_name} /tree/${branch} ) | [Open](${main_deployment_url} ) |" >> $deployments_list
45+
46+ remote_branches=$( git ls-remote --heads origin | sed ' s?.*refs/heads/??' | grep -v " gh-pages" | grep -v " ${main_git_branch} " )
47+ echo " $remote_branches " | while IFS= read -r branch; do
48+ branch_slug=$( slugify $branch )
49+ deployment_url=" https://${github_repo_owner} .github.io/${github_repo_name} /branches/${branch_slug} "
50+ echo " | [${branch} ](https://github.com/${github_repo_owner} /${github_repo_name} /tree/${branch} ) | [Open](${deployment_url} ) |" >> $deployments_list
51+ done
52+
53+ # Update gh-pages branch
54+ git add --all
55+ git commit --allow-empty -m " Update ${deployments_list} [ci skip]"
56+ git push --force origin gh-pages
57+ }
58+
59+ export -f update_deployments_list
0 commit comments