update webpack.yml #34
Workflow file for this run
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
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 folder contents | |
run: | | |
cp -r docs/ | |
- name: Checkout to build branch | |
run: | | |
git fetch | |
git checkout build | |
echo "Checkout to branch :build" | |
- name: Paste folder contents | |
run: | | |
mv docs/ | |
- name: Commit changes | |
run: | | |
git add docs/ | |
version=$(echo "${{ github.ref }}" | sed 's/refs\/tags\/v//') | |
echo "Tag version: $version" | |
git commit -m "update version to v$version" | |
git push | |