Fix GitHub Actions configuration for version bumping and tag pushing #8
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: Build and Deploy | |
on: | |
push: | |
branches: | |
- main # change this to your default branch name if it's not 'main' | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 20 | |
- name: Install Dependencies | |
run: npm ci | |
- name: Test | |
run: npm run ci:test | |
- name: Bump version and push tag | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
npm version patch -m "Bump version to %s [skip ci]" | |
git remote set-url origin https://x-access-token:[email protected]/${{ github.repository }} | |
git push origin --tags | |
- name: Build | |
run: npm run build:prod | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: dist | |
path: dist/chuck-norris-joke-generator/browser | |
- name: Deploy | |
uses: JamesIves/[email protected] | |
with: | |
branch: gh-pages # The branch the action should deploy to. | |
folder: dist/chuck-norris-joke-generator/browser # The folder the action should deploy. | |
token: ${{ secrets.GH_TOKEN }} # The GitHub token. |