Merge pull request #34 from line/dev #20
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: Vite Github Pages Deploy | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push or pull request events but only for the "main" branch | |
push: | |
branches: ["main"] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
jobs: | |
# Build job | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Pages | |
uses: actions/configure-pages@v3 | |
- name: Install | |
run: npm i | |
- name: Build | |
run: npm run build | |
env: | |
NODE_ENV: production | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
path: ./dist | |
# Deployment job | |
deploy: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 | |
# Tagging job | |
tag: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: "0" | |
- name: Read packages.json | |
run: | | |
echo "PACKAGE_JSON=$(jq -c . < package.json)" >> $GITHUB_ENV | |
- name: Generate tag version (headver) | |
run: | | |
VERSION_PREFIX="v" | |
VERSION_HEAD=$(cut -d '.' -f 1 <<< ${{ fromJson(env.PACKAGE_JSON).version }}) | |
VERSION_YEAR=$(date +%g) | |
VERSION_WEEK=$(date +%V) | |
VERSION_BUILD=${{github.run_number}} | |
NEW_TAG="${VERSION_PREFIX}${VERSION_HEAD}.${VERSION_YEAR}${VERSION_WEEK}.${VERSION_BUILD}" | |
echo "Generated new tag: $NEW_TAG" | |
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV | |
- name: Push Git Tag | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
git tag $NEW_TAG | |
git push origin $NEW_TAG |