Skip to content

Commit 4565801

Browse files
committed
Handle branch deletion
1 parent ebaebfc commit 4565801

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

.github/workflows/branch-deleted.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- uses: actions/checkout@v2
1111
with:
1212
fetch-depth: 0
13-
ref: gh-pages
13+
ref: hakyll
1414

1515
- name: Remove stale deployments
1616
run: ./.github/workflows/deployment/delete.sh $GITHUB_REF_NAME

.github/workflows/deployment/commons.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ slugify() {
1414
echo "$1" | iconv -c -t ascii//TRANSLIT | sed -E 's/[~^]+/-/g' | sed -E 's/[^a-zA-Z0-9]+/-/g' | sed -E 's/^-+|-+$/-/g' | tr A-Z a-z
1515
}
1616
export -f slugify
17+
18+
git config user.name github-actions
19+
git config user.email [email protected]
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
#!/usr/bin/env bash
22

33
# Remove deployment by specified git branch name.
4-
# Script assumes that you are on gh-pages branch.
54

65
set -eo pipefail
76

87
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
98
source $script_dir/commons.sh
109

11-
branch_slug=$($script_dir/slugify.sh $1)
10+
git checkout gh-pages
11+
git pull origin gh-pages
1212

13+
branch_slug=$($script_dir/slugify.sh $1)
1314
rm -rf "$deployments_dir/$branch_slug"
15+
16+
echo "Updating gh-pages branch."
17+
git add --all
18+
git commit --allow-empty -m "Delete '${$1}' branch deployment [ci skip]"
19+
git push --force origin gh-pages
20+
echo "Deployment for branch '$1' has been deleted."

.github/workflows/deployment/deploy.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ set -eo pipefail
77
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
88
source $script_dir/commons.sh
99

10-
git config user.name github-actions
11-
git config user.email [email protected]
12-
1310
deploy() {
1411
if [[ ! -z "$GITHUB_REF_NAME" ]]; then
1512
# The GITHUB_REF_NAME env variable is available in github actions.
@@ -47,7 +44,7 @@ deploy() {
4744

4845
echo "Updating gh-pages branch."
4946
git add --all
50-
git commit --allow-empty -m "[$(date '+%F %T %Z')] Updated site for the '${git_branch}' branch [ci skip]"
47+
git commit --allow-empty -m "Update '${git_branch}' branch deployment [ci skip]"
5148
git push --force origin gh-pages
5249
echo "Deployment finished."
5350
}
@@ -86,7 +83,7 @@ update_deployments_list() {
8683

8784
# Update gh-pages branch
8885
git add --all
89-
git commit --allow-empty -m "Update ${deployments_list}"
86+
git commit --allow-empty -m "Update ${deployments_list} [ci skip]"
9087
git push --force origin gh-pages
9188
}
9289

0 commit comments

Comments
 (0)