diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 551e0ea20..abc331191 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -7,27 +7,48 @@ on: branches: [ master ] workflow_dispatch: +permissions: + contents: read + pull-requests: write + jobs: cypress-run: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - + - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 18 cache: 'npm' - - name: Install lockfile run: npm ci - - name: Run Cypress Tests + id: cypress run: npm run cy:ci - - - name: Publish Report + - name: Upload PR Report + if: github.event_name == 'pull_request' && always() uses: actions/upload-artifact@v4 - if: always() with: - name: cypress + name: cypress-reports-pr-${{ github.event.pull_request.number }} path: cypress/reports/html + retention-days: 7 + - name: Upload Reports + if: github.event_name != 'pull_request' && always() + uses: actions/upload-artifact@v4 + with: + name: cypress-reports-${{ github.ref_name }}-${{ github.run_number }} + path: cypress/reports/html + retention-days: 28 + - name: Comment on PR + if: github.event_name == 'pull_request' && always() + uses: actions/github-script@v7 + with: + script: | + const emoji = '${{ steps.cypress.outcome }}' === 'success' ? '✅' : '❌'; + const url = `https://${context.repo.owner}.github.io/${context.repo.repo}/reports/cypress-reports-pr-${context.issue.number}/` + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `${emoji} Cypress report available at: ${url}` + }) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 000000000..e6667dcf6 --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,117 @@ +name: GitHub Pages + +on: + push: + branches: [ master ] + workflow_run: + workflows: ["Cypress"] + types: + - completed + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/configure-pages@v5 + + # Create site directory + - name: Create site directory + run: | + mkdir -p _build _site + cp README.md _build/ + cp -r docs _build/ + + # Build docs from root + - uses: actions/jekyll-build-pages@v1 + with: + source: ./_build + destination: ./_site + + # Download and merge any test reports + - name: Process Reports + run: | + mkdir -p "_site/reports" + gh auth login --with-token <<< "${{ github.token }}" + gh run download --pattern "cypress-reports-*" --dir _site/reports + # Create copy of latest master report + latest_master=$(ls -td _site/reports/cypress-reports-master-* 2>/dev/null | head -1) + if [ -n "$latest_master" ] && [ -d "$latest_master" ]; then + mkdir -p _site/reports/latest-master + cp -r "$latest_master/." _site/reports/latest-master/ + fi + cat > _site/reports/index.html << EOF + + +
+