Update versions hopefully #16
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: Angular CI/CD to GitHub Pages | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [14.x, 18.x, 20.x] # Use the versions that you need | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
- name: Install Dependencies | |
run: npm ci | |
- name: Build Angular App | |
run: npm run build # It will use the build command defined in package.json | |
# No need for working-directory if the root is correct | |
- name: Run Tests | |
run: npm test # It will use the test command defined in package.json | |
# This step will only run when the workflow is triggered by a push to the main branch | |
# and when the matrix is using the Node.js version 20.x | |
- name: Deploy to GitHub Pages | |
if: github.ref == 'refs/heads/main' && matrix.node-version == '20.x' | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
branch: main # The branch you are deploying to (GitHub Pages) | |
folder: docs # The folder that your Angular app is outputting to (configured in angular.json) | |
token: ${{ secrets.GITHUB_TOKEN }} # GitHub automatically creates this secret to use in workflows |