Skip to content

Commit

Permalink
Create webpack.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
s956142 committed Apr 20, 2024
1 parent 22fbf79 commit 7d687c0
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/webpack.yml
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



0 comments on commit 7d687c0

Please sign in to comment.