Skip to content

Build and Deploy

Build and Deploy #3

name: Build and Deploy
on:
# push:
# branches:
# - main
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions: write-all
env:
VITE_AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
VITE_SECRET_INJECTION_TEST: ${{ secrets.SECRET_INJECTION_TEST }}
VITE_MY_MICROSOFT_EMAIL: ${{ secrets.MY_MICROSOFT_EMAIL }}
VITE_GITHUB_REPO: ${{ github.event.repository.name }}
VITE_GITHUB_OWNER: ${{ github.event.repository.owner.login }}
VITE_GITHUB_FILE_PATH: "public/me.jpeg"
VITE_GITHUB_PRESENCE_PATH: "public/me.json"
VITE_PUT_FILE_PAT: ${{ secrets.PUT_FILE_PAT }}
VITE_BASE_URL: 'https://cynicdog.github.io/azure-entra-in-spa'
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Set up Node.js
uses: actions/[email protected]
with:
node-version: '16'
cache: 'npm'
- name: Cache NPM dependencies
id: cache-npm-deps
uses: actions/cache@v4
with:
path: |
~/.npm
node_modules
key: node-cache-${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
node-cache-${{ runner.os }}-npm-
- name: Install dependencies
if: steps.cache-npm-deps.outputs.cache-hit != 'true'
run: npm install
- name: Build the app
run: npm run build
- name: Pre-deploy to GitHub Pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run predeploy
- name: Configure git to use HTTPS and set credentials
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
- name: Deploy to GitHub Pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm run deploy