diff --git a/.github/workflows/webpack.yml b/.github/workflows/webpack.yml new file mode 100644 index 0000000..94a6306 --- /dev/null +++ b/.github/workflows/webpack.yml @@ -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 + + + + \ No newline at end of file