From 8c09b9deb91563ac56019b609247c7add51e255c Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Fri, 12 May 2023 19:47:45 +0200 Subject: [PATCH] Update gh pages workflow --- .github/workflows/deploy-to-gh-pages.yml | 71 ++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/.github/workflows/deploy-to-gh-pages.yml b/.github/workflows/deploy-to-gh-pages.yml index e69de29..9107f59 100644 --- a/.github/workflows/deploy-to-gh-pages.yml +++ b/.github/workflows/deploy-to-gh-pages.yml @@ -0,0 +1,71 @@ + +name: Build and Deploy +on: + push: + branches: + - main + - master + +jobs: + build-and-deploy: + + strategy: + matrix: + folder: + - ./ + + runs-on: ubuntu-latest + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v2.3.1 + + - name: Read package.json node and npm engines version + uses: skjnldsv/read-package-engines-version-actions@v1.1 + id: versions + with: + path: ${{matrix.folder}} + fallbackNode: '^12' + fallbackNpm: '^6' + + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} + uses: actions/setup-node@v2 + with: + node-version: ${{ steps.versions.outputs.nodeVersion }} + + - name: Set up npm ${{ steps.versions.outputs.npmVersion }} + run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" + + - name: Cache node modules + uses: actions/cache@v1 + env: + cache-name: cache-node-modules + with: + path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Install and Build 🔧 + env: + REPO_NAME: ${{ github.event.repository.name }} + run: | + cd ${{matrix.folder}} + npm install + npm run build + + - name: Create branch + uses: peterjgrainger/action-create-branch@v2.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + branch: gh-pages + + - name: Deploy 🚀 + uses: JamesIves/github-pages-deploy-action@4.1.5 + with: + branch: gh-pages + folder: ${{ matrix.folder }}/dist + target-folder: ${{ matrix.folder }} + token: ${{ secrets.GITHUB_TOKEN }}