-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: NodeJS with Webpack | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
build_and_commit: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [18.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Get tag version number | ||
run: | | ||
# 取得版本號碼 | ||
version=$(echo "${{ github.ref }}" | sed 's/refs\/tags\/v//') | ||
echo "Tag version: $version" | ||
echo "::set-output name=version::$version" | ||
- name: Get author from commit or tag | ||
run: | | ||
# get author from commit | ||
commit_author=$(git log -1 --pretty=format:"%an") | ||
commit_email=$(git log -1 --pretty=format:"%ae") | ||
echo "Commit author name: $commit_author" | ||
echo "Commit author email: $commit_email" | ||
# get author from tag | ||
tag_commit=$(git rev-list -n 1 ${{ github.ref }}) | ||
tag_author=$(git show -s --format="%an" $tag_commit) | ||
tag_email=$(git show -s --format="%ae" $tag_commit) | ||
echo "Tag author name: $tag_author" | ||
echo "Tag author email: $tag_email" | ||
git config --global user.name "$tag_author" | ||
git config --global user.email "$tag_email" | ||
- name: Install dependencies | ||
run: yarn | ||
|
||
- name: Build project | ||
run: yarn build | ||
|
||
- name: Copy docs to build branch | ||
run: | | ||
cp -r docs/ docs_copy/ | ||
git fetch | ||
git checkout build | ||
echo "Checkout to branch :build" | ||
rm -rf docs/ | ||
mv docs_copy/ docs/ | ||
- name: Commit changes | ||
run: | | ||
git add docs/ -f | ||
version=$(echo "${{ github.ref }}" | sed 's/refs\/tags\/v//') | ||
echo "Tag version: $version" | ||
git commit -m "update version to v$version" | ||
git push | ||
|
||
|
||
|