File tree 6 files changed +60
-78
lines changed
actions/deploy-dir-as-branch
6 files changed +60
-78
lines changed Original file line number Diff line number Diff line change 4
4
/coverage
5
5
/npmDist
6
6
/denoDist
7
- /npm
8
- /deno
9
7
10
8
# Ignore TS files inside integration test
11
9
/integrationTests /ts /* .ts
Original file line number Diff line number Diff line change
1
+ name : ' Deploy specified directory as a branch'
2
+ description : ' This action deploys directory as branch.'
3
+ inputs :
4
+ src_dir :
5
+ required : true
6
+ target_branch :
7
+ required : true
8
+ runs :
9
+ using : ' composite'
10
+ steps :
11
+ - name : Creating temporary directory to clone the branch
12
+ shell : bash
13
+ run : |
14
+ BRANCH_DIR=$(mktemp -d "`pwd`/cloned_${{ inputs.target_branch }}_XXXXXX")
15
+ echo "BRANCH_DIR=$BRANCH_DIR" >> $GITHUB_ENV
16
+
17
+ - name : Checkout `${{ inputs.target_branch }}` branch
18
+ uses : actions/checkout@v2
19
+ with :
20
+ ref : ${{ inputs.target_branch }}
21
+ path : ${{ env.BRANCH_DIR }}
22
+
23
+ - name : Publish `${{ inputs.target_branch }}` branch
24
+ working-directory : ${{ env.BRANCH_DIR }}
25
+ shell : bash
26
+ run : |
27
+ echo '::echo::on'
28
+
29
+ echo '::group::Remove existing files first'
30
+ git rm -r .
31
+ echo '::endgroup::'
32
+
33
+ echo '::group::Move necessary files'
34
+ cp -vnR '${{ github.workspace }}/${{ inputs.src_dir }}/.' .
35
+ echo '::endgroup::'
36
+
37
+ git add -A
38
+ if git diff --staged --quiet; then
39
+ echo 'Nothing to publish'
40
+ else
41
+ git config user.name 'GitHub Action Script'
42
+ git config user.email '[email protected] '
43
+
44
+ git commit -a -m 'Deploy ${{ github.sha }} to '${{ inputs.target_branch }}' branch'
45
+ git push
46
+ echo 'Pushed'
47
+ fi
48
+
49
+ - name : Remove cloned branch
50
+ if : ${{ always() }}
51
+ shell : bash
52
+ run : ' rm -rf $BRANCH_DIR'
Original file line number Diff line number Diff line change @@ -243,9 +243,10 @@ jobs:
243
243
run : npm run build:npm
244
244
245
245
- name : Deploy to `npm` branch
246
- run : npm run gitpublish:npm
247
- env :
248
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
246
+ uses : ./.github/actions/deploy-dir-as-branch
247
+ with :
248
+ src_dir : npmDist
249
+ target_branch : npm
249
250
250
251
deploy-to-deno-branch :
251
252
name : Deploy to `deno` branch
@@ -272,6 +273,7 @@ jobs:
272
273
run : npm run build:deno
273
274
274
275
- name : Deploy to `deno` branch
275
- run : npm run gitpublish:deno
276
- env :
277
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
276
+ uses : ./.github/actions/deploy-dir-as-branch
277
+ with :
278
+ src_dir : denoDist
279
+ target_branch : deno
Original file line number Diff line number Diff line change 12
12
/coverage
13
13
/npmDist
14
14
/denoDist
15
- /npm
16
- /deno
Original file line number Diff line number Diff line change 5
5
/coverage
6
6
/npmDist
7
7
/denoDist
8
- /npm
9
- /deno
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments