Skip to content

fix: release automation configured #11

fix: release automation configured

fix: release automation configured #11

Workflow file for this run

name: Deploy to GitHub Pages Prod
on:
push:
branches:
- main
workflow_dispatch:
# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages
permissions:
contents: write
pages: write
id-token: write
actions: write
# Allow one concurrent deployment
concurrency:
group: 'pages'
cancel-in-progress: true
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Set build mode
run: |
if [[ $GITHUB_REF == 'refs/heads/dev' ]]; then
echo "NODE_ENV=development" >> $GITHUB_ENV
echo "BUILD_MODE=development" >> $GITHUB_ENV
else
echo "NODE_ENV=production" >> $GITHUB_ENV
echo "BUILD_MODE=production" >> $GITHUB_ENV
fi
- name: Build project
run: |
if [[ $GITHUB_REF == 'refs/heads/dev' ]]; then
npm run build:dev
else
npm run build:prod
fi
- name: Deploy main to root
if: github.ref == 'refs/heads/main'
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: dist # Use the production build folder
target-folder: '' # Deploy to the root folder
token: ${{ secrets.GITHUB_TOKEN }}
clean: true # Clear root before deploying main
- name: Set up Git user
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Set up GH_TOKEN for release
run: echo "GH_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
- name: Show recent commits and tags
run: |
git log --oneline -n 5
git tag
- name: Show auto info
run: npx auto info
- name: Release with auto
if: github.ref == 'refs/heads/main'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run release
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: ${{ github.ref == 'refs/heads/dev' && 'dist/dev' || 'dist' }} # Deploy from dist/dev for dev branch, dist for main (prod)
target-folder: ${{ github.ref == 'refs/heads/dev' && 'dev' || '' }} # Deploy to /dev for dev branch, root for main
token: ${{ secrets.GITHUB_TOKEN }}
force: false