From b17f786b135915a925b9afa869c6eb7cdef2d164 Mon Sep 17 00:00:00 2001 From: Daniel Rauf Date: Tue, 15 Aug 2023 08:21:55 +0200 Subject: [PATCH] Create test-and-deploy.yml workflow --- .github/workflows/test-and-deploy.yml | 86 +++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .github/workflows/test-and-deploy.yml diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml new file mode 100644 index 0000000..33c6331 --- /dev/null +++ b/.github/workflows/test-and-deploy.yml @@ -0,0 +1,86 @@ +name: Test and deploy to Pages + +on: + # Runs on pushes targeting the default branch and pull requests + push: + branches: ["main"] + pull_request: + + # Allows to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +jobs: + test: + runs-on: ubuntu-latest + container: + image: mcr.microsoft.com/playwright:next-jammy + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node 20 + uses: actions/setup-node@v3 + with: + node-version: "20" + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v3 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - run: yarn install --frozen-lockfile --immutable + - run: yarn lint + - run: yarn test + + - name: Install Playwright browsers + run: yarn playwright install --with-deps + - name: Run Playwright tests + run: HOME=/root yarn playwright test + - name: Upload Playwright report + uses: actions/upload-artifact@v3 + if: failure() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 + + - name: Build static page for deployment + run: yarn predeploy + - name: Upload artifact for deployment + uses: actions/upload-pages-artifact@v2 + with: + path: ./build + + deploy: + needs: test + runs-on: ubuntu-latest + if: github.ref_name == "main" + + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. + # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. + concurrency: + group: "pages" + cancel-in-progress: false + + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2