From 891c5715b303b176c0ae11608c95d8eb06549e72 Mon Sep 17 00:00:00 2001 From: fsegurai <42953884+fsegurai@users.noreply.github.com> Date: Wed, 5 Jun 2024 12:17:33 -0600 Subject: [PATCH] Create angular-CI_CD.yml --- .github/workflows/angular-CI_CD.yml | 68 +++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/angular-CI_CD.yml diff --git a/.github/workflows/angular-CI_CD.yml b/.github/workflows/angular-CI_CD.yml new file mode 100644 index 0000000..189f33c --- /dev/null +++ b/.github/workflows/angular-CI_CD.yml @@ -0,0 +1,68 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: Angular CI/CD + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + workflow_dispatch: + +permissions: + contents: write + pages: write + id-token: write + +env: + PROJECT_DIR: dist/demo/browser + +jobs: + build_test_merge: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [ 18.x ] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + + - name: Create cache directories + run: mkdir -p ~/.cache/yarn && mkdir -p ${{ github.workspace }}/.yarn + + - name: Cache Yarn dependencies + uses: actions/cache@v4 # this allows for re-using node_modules caching, making builds a bit faster. + with: + path: | + ~/.cache/yarn + ${{ github.workspace }}/.yarn + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Test Angular project + run: yarn test:ci_cd + + - name: Build Angular project demo + run: yarn build:demo + + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ${{ env.PROJECT_DIR }} + publish_branch: gh-pages