2020-05-07 05:54:08 +08:00
name : ci
2019-09-01 06:30:48 +08:00
2023-05-07 05:11:07 +08:00
concurrency :
group : ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress : true
2019-09-01 06:30:48 +08:00
on :
2020-05-09 21:11:59 +08:00
schedule :
2022-10-19 03:49:55 +08:00
- cron : '0 10 * * *'
2019-09-01 06:30:48 +08:00
push :
branches :
2021-03-16 06:35:50 +08:00
- 'dev'
- 'releases/v*'
2021-05-13 08:23:35 +08:00
pull_request :
2019-09-01 06:30:48 +08:00
jobs :
2020-05-07 05:54:08 +08:00
ci :
2019-09-01 06:30:48 +08:00
runs-on : ubuntu-latest
2020-11-12 13:27:44 +08:00
strategy :
fail-fast : false
matrix :
include :
- target_branch : 'gh-pages'
keep_history : 'false'
2021-05-30 11:00:48 +08:00
verbose : 'true'
2020-11-12 13:27:44 +08:00
- target_branch : 'gh-pages-keep'
keep_history : 'true'
2021-05-30 11:00:48 +08:00
verbose : 'false'
2019-09-01 06:30:48 +08:00
steps :
-
name : Checkout
2023-09-05 00:14:47 +08:00
uses : actions/checkout@v4
2020-04-09 06:59:11 +08:00
-
2020-11-12 13:27:44 +08:00
name : Init
2019-09-01 06:30:48 +08:00
run : |
2020-11-12 13:27:44 +08:00
sudo apt-get install tree
2019-09-01 06:30:48 +08:00
mkdir public
2020-11-12 13:27:44 +08:00
-
name : Gen dummy files and folders
run : |
MAXDIRS=5
MAXDEPTH=5
2021-05-30 11:00:48 +08:00
MAXFILES=30
MAXSIZE=3000
2020-11-12 13:27:44 +08:00
TOP=$(pwd|tr -cd '/'|wc -c)
populate() {
cd $1
curdir=$PWD
files=$(($RANDOM*$MAXFILES/32767))
for n in $(seq $files)
do
f=$(mktemp XXXXXX)
size=$(($RANDOM*$MAXSIZE/32767))
head -c $size /dev/urandom > $f
done
depth=$(pwd | tr -cd '/' | wc -c)
if [ $(($depth-$TOP)) -ge $MAXDEPTH ]
then
return
fi
unset dirlist
dirs=$(($RANDOM*$MAXDIRS/32767))
for n in $(seq $dirs); do
d=`mktemp -d XXXXXX`
dirlist="$dirlist${dirlist:+ }$PWD/$d"
done
for dir in $dirlist; do
populate "$dir"
done
}
populate $PWD/public
-
name : Gen dummy page
run : |
2019-09-01 06:30:48 +08:00
cat > public/index.html <<EOL
<!doctype html>
<html>
<head>
<title>GitHub Pages deployed!</title>
</head>
<body>
2020-05-04 07:22:35 +08:00
<p>GitHub Pages with <strong>${{ github.sha }}</strong> commit ID has been deployed through <a href="https://github.com/marketplace/actions/github-pages">GitHub Pages action</a> successfully on <strong>$(date)</strong>.</p>
2019-09-01 06:30:48 +08:00
</body>
</html>
EOL
2020-11-12 13:27:44 +08:00
tree -f -h ./public
2020-06-28 10:07:30 +08:00
-
name : Check GitHub Pages status
2022-05-27 05:28:32 +08:00
uses : crazy-max/ghaction-github-status@v3
2020-06-28 10:07:30 +08:00
with :
pages_threshold : major_outage
2019-09-01 06:30:48 +08:00
-
name : Deploy
2019-10-11 07:41:16 +08:00
uses : ./
2019-09-01 06:30:48 +08:00
with :
2020-11-12 13:27:44 +08:00
target_branch : ${{ matrix.target_branch }}
keep_history : ${{ matrix.keep_history }}
2019-09-01 06:30:48 +08:00
build_dir : public
2021-05-30 11:00:48 +08:00
dry_run : ${{ github.event_name == 'pull_request' }}
verbose : ${{ matrix.verbose }}
2022-01-12 17:03:22 +08:00
jekyll : false
2019-09-01 06:30:48 +08:00
env :
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}