Skip to content

Commit c552f3f

Browse files
Merge pull request #20 from monikakonieczna/Task-14-GitHub-Page-For-Test-report
Task 14 Deploy GitHub Page for Jest Report
2 parents 1c63e20 + d71b165 commit c552f3f

File tree

5 files changed

+97
-52
lines changed

5 files changed

+97
-52
lines changed

.github/workflows/deploy-static-html.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Publish jest report using 2 seperated jobs
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
jobs:
18+
test:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout Repository
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: '20.x'
29+
30+
- name: Install dependencies
31+
run: npm install
32+
33+
- name: Run Sanity Tests And Generate Report
34+
run: npm run test:sanity
35+
36+
- name: Upload Test Results
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: my-artifact
40+
path: test-results/report
41+
42+
43+
deploy:
44+
needs: test
45+
environment:
46+
name: github-pages
47+
url: ${{ steps.deployment.outputs.page_url }}
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@v4
52+
53+
- name: Setup Pages
54+
uses: actions/configure-pages@v4
55+
56+
- name: Download artifacts
57+
uses: actions/download-artifact@v4
58+
59+
- name: Upload Artifact
60+
uses: actions/upload-pages-artifact@v3
61+
with:
62+
path: my-artifact
63+
64+
- name: Deploy to GitHub Pages
65+
id: deployment
66+
uses: actions/deploy-pages@v4

.github/workflows/publish-report.yml

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,20 @@ on:
66
workflow_dispatch:
77

88
permissions:
9-
contents: write
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
1016

1117
jobs:
12-
test:
18+
deploy:
19+
environment:
20+
name: github-pages
21+
url: ${{ steps.deployment.outputs.page_url }}
22+
1323
runs-on: ubuntu-latest
1424

1525
steps:
@@ -27,10 +37,17 @@ jobs:
2737
- name: Run Sanity Tests And Generate Report
2838
run: npm run test:sanity
2939

30-
- name: Deploy to GitHub Pages
31-
if: success()
32-
uses: peaceiris/actions-gh-pages@v4
40+
- name: Setup Pages
41+
uses: actions/configure-pages@v4
42+
43+
- name: Download artifacts
44+
uses: actions/download-artifact@v4
45+
46+
- name: Upload Artifact
47+
uses: actions/upload-pages-artifact@v3
3348
with:
34-
github_token: ${{ secrets.GITHUB_TOKEN }}
35-
publish_dir: ./test-results
36-
publish_branch: gh-pages
49+
path: test-results/report
50+
51+
- name: Deploy to GitHub Pages
52+
id: deployment
53+
uses: actions/deploy-pages@v4

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,8 @@ This repository includes a GitHub Actions workflow that allows you to run specif
161161
- `single_character`: Runs tests related to a single character.
162162
- `all_characters`: Runs tests for all characters.
163163
- `multiple_characters`: Runs tests involving multiple characters.
164-
- `filter_characters`: Runs tests that filter characters.
164+
- `filter_characters`: Runs tests that filter characters.
165+
166+
### GitHub Actions - Publish Jest Report as GitHub Page
167+
168+
### Workflow Details:

jest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const config: Config.InitialOptions = {
99
"default",
1010
[
1111
"jest-html-reporter",
12-
{ outputPath: "test-results/test-results.html"},
12+
{ outputPath: "test-results/report/index.html"},
1313
],
1414
],
1515
};

0 commit comments

Comments
 (0)