File tree 2 files changed +63
-6
lines changed
2 files changed +63
-6
lines changed Original file line number Diff line number Diff line change
1
+ name : Deploy
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - master
7
+ - source
8
+ pull_request :
9
+ branches :
10
+ - master
11
+ - source
12
+
13
+ jobs :
14
+ deploy :
15
+ runs-on : ubuntu-latest
16
+ steps :
17
+ - name : Checkout code
18
+ uses : actions/checkout@v2
19
+ - name : Setup Ruby
20
+ uses : actions/setup-ruby@v1
21
+ - name : Enable bundler cache
22
+ uses : actions/cache@v2
23
+ with :
24
+ path : vendor/bundle
25
+ key : ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
26
+ restore-keys : |
27
+ ${{ runner.os }}-gems-
28
+ - name : Install deps
29
+ run : |
30
+ gem install bundler
31
+ bundle config path vendor/bundle
32
+ bundle install --jobs 4 --retry 3
33
+ - name : Setup deploy options
34
+ id : setup
35
+ run : |
36
+ git config --global user.name "GitHub Action"
37
+ git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
38
+ if [[ ${GITHUB_REF} = refs/pull/*/merge ]]; then # pull request
39
+ echo "::set-output name=SRC_BRANCH::${GITHUB_HEAD_REF}"
40
+ echo "::set-output name=DRY_RUN::--dry-run"
41
+ elif [[ ${GITHUB_REF} = refs/heads/* ]]; then # branch, e.g. master, source etc
42
+ echo "::set-output name=SRC_BRANCH::${GITHUB_REF#refs/heads/}"
43
+ fi
44
+ if [[ ${{ github.repository }} = *.github.io ]]; then # user/org repo
45
+ echo "::set-output name=DEPLOY_BRANCH::master"
46
+ else
47
+ echo "::set-output name=DEPLOY_BRANCH::gh-pages"
48
+ fi
49
+ - name : Deploy website
50
+ run : yes | bin/deploy --verbose ${{ steps.setup.outputs.DRY_RUN }}
51
+ --src ${{ steps.setup.outputs.SRC_BRANCH }}
52
+ --deploy ${{ steps.setup.outputs.DEPLOY_BRANCH }}
Original file line number Diff line number Diff line change 7
7
SRC_BRANCH=" master"
8
8
DEPLOY_BRANCH=" gh-pages"
9
9
10
- USAGE_MSG=" usage: deploy [-h|--help] [-u|--user] [-s|--src SRC_BRANCH] [-d|--deploy DEPLOY_BRANCH]"
10
+ USAGE_MSG=" usage: deploy [-h|--help] [-u|--user] [-s|--src SRC_BRANCH] [-d|--deploy DEPLOY_BRANCH] [--verbose] [--dry-run] "
11
11
12
12
while [[ $# > 0 ]]; do
13
13
key=" $1 "
@@ -20,7 +20,6 @@ while [[ $# > 0 ]]; do
20
20
-u|--user)
21
21
SRC_BRANCH=" source"
22
22
DEPLOY_BRANCH=" master"
23
- shift
24
23
;;
25
24
-s|--src)
26
25
SRC_BRANCH=" $2 "
@@ -30,10 +29,16 @@ while [[ $# > 0 ]]; do
30
29
DEPLOY_BRANCH=" $2 "
31
30
shift
32
31
;;
32
+ --verbose)
33
+ set -x
34
+ ;;
35
+ --dry-run)
36
+ DRY_RUN=" --dry-run"
37
+ ;;
33
38
* )
34
- echo " Option $1 is unknown."
35
- echo $USAGE_MSG
36
- exit 0
39
+ echo " Option $1 is unknown." >&2
40
+ echo $USAGE_MSG >&2
41
+ exit 1
37
42
;;
38
43
esac
39
44
shift
@@ -88,7 +93,7 @@ rm -R _site/
88
93
# Push to DEPLOY_BRANCH
89
94
git add -fA
90
95
git commit --allow-empty -m " $( git log -1 --pretty=%B) [ci skip]"
91
- git push -f -q origin $DEPLOY_BRANCH
96
+ git push ${DRY_RUN} -f -q origin $DEPLOY_BRANCH
92
97
93
98
# Move back to SRC_BRANCH
94
99
git checkout $SRC_BRANCH
You can’t perform that action at this time.
0 commit comments