From e66656363a9467a05f0e49dfbc06d419653378f8 Mon Sep 17 00:00:00 2001 From: Reza Jafar Date: Thu, 23 May 2024 13:55:52 -0700 Subject: [PATCH] chore: Update node versions and add pull request trigger in deploy.yml workflow --- .github/workflows/deploy.yml | 14 ++++++--- .github/workflows/node.js.yml | 36 ++++++++++++++++++++++ .github/workflows/studio.yml | 57 +++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/node.js.yml create mode 100644 .github/workflows/studio.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b383a547e..d7ac8f49d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,9 +1,12 @@ -name: Deploy to Netlify +name: Build and Deploy to Netlify on: push: branches: - 'main' + pull_request: + branches: + - 'main' workflow_dispatch: permissions: @@ -19,21 +22,24 @@ jobs: strategy: matrix: - node: [20.x] + node-version: [14.x, 16.x, 18.x, 20.x] steps: - name: Checkout code uses: actions/checkout@v4 - - name: Set up Node.js ${{ matrix.node }} + - name: Set up Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node }} + node-version: ${{ matrix.node-version }} cache: 'yarn' - name: Install dependencies run: yarn install + - name: Run tests + run: yarn test + - name: Install @nuxthq/studio run: yarn add -D @nuxthq/studio diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 000000000..16292d76e --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,36 @@ +name: Node.js CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.x, 16.x, 18.x, 20.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + + - name: Install dependencies + run: yarn install + + - name: Run tests + run: yarn test + + - name: Build project + run: yarn build diff --git a/.github/workflows/studio.yml b/.github/workflows/studio.yml new file mode 100644 index 000000000..b03aeb04b --- /dev/null +++ b/.github/workflows/studio.yml @@ -0,0 +1,57 @@ +name: Studio Nuxt Build + +on: + push: + branches: + - 'main' + workflow_dispatch: + +permissions: + contents: write + +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + strategy: + matrix: + node: [20.x] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js ${{ matrix.node }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + cache: 'yarn' + + - name: Install dependencies + run: yarn install + + - name: Install @nuxthq/studio + run: yarn add -D @nuxthq/studio + + - name: Create .nuxtrc + run: echo $'\nautoImport=true\nmodules[]=@nuxthq/studio' >> .nuxtrc + + - name: Build project + run: npx nuxi build + env: + NUXT_UI_PRO_LICENSE: ${{ secrets.NUXT_UI_PRO_LICENSE }} + NUXT_PUBLIC_STUDIO_API_URL: https://api.nuxt.studio + NUXT_PUBLIC_STUDIO_TOKENS: ${{ secrets.NUXT_PUBLIC_STUDIO_TOKENS }} + NUXT_PUBLIC_SITE_URL: ${{ secrets.NUXT_PUBLIC_SITE_URL }} + + - name: Deploy to Netlify + uses: netlify/actions/cli@master + with: + args: deploy --dir=.output/public --prod + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}