Skip to content

Commit

Permalink
Generate report number manually
Browse files Browse the repository at this point in the history
  • Loading branch information
NabinKawan committed Apr 11, 2024
1 parent 673fd7b commit 93c5dc4
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions .github/workflows/test_integration_playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Integration Test [Playwright]

on:
push:
branches: [main]
branches: [main, feat/playwright-tests]
pull_request:
branches: [main]

Expand All @@ -21,7 +21,6 @@ jobs:
KUBER_API_URL: ${{vars.KUBER_API_URL}}
KUBER_API_KEY: ${{secrets.KUBER_API_KEY}}
WORKERS: ${{vars.WORKERS}}
GH_PAGES: ${{vars.GH_PAGES}}

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -79,7 +78,7 @@ jobs:
if: ${{success()}}
run: |
mkdir project
cp -r gh-pages/* project
cp -r gh-pages/* project || true
if grep -q ${{github.repository}} project/projects.txt; then
echo "Project already exists"
echo "::set-output name=project_exists::true"
Expand All @@ -96,6 +95,18 @@ jobs:
repository-name: ${{vars.GH_PAGES}}
branch: gh-pages
folder: project

- name: Generate report number
id: report_num
run: |
gh_pages_content=$(ls gh-pages/${{github.repository}}) || ''
if [[ -z "$gh_pages_content" ]]; then
latest_number=0
else
latest_number=$(echo "$gh_pages_content" | grep -Eo '[0-9]+' | sort -nr | head -n 1)
fi
echo "::set-output name=number::$latest_number"
- name: Build report
uses: simple-elf/allure-report-action@master
Expand All @@ -107,6 +118,8 @@ jobs:
allure_report: allure-report
allure_history: allure-history
keep_reports: 2000
report_url: https://${{vars.GH_PAGES}}/govtool-test-reports
github_run_num: ${{steps.report_num.outputs.number}}

- name: Generate Latest Report Redirect
run: |
Expand All @@ -118,24 +131,24 @@ jobs:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=/allure-report/${{ github.repository }}/${{ github.run_number }}/index.html">
<meta http-equiv="refresh" content="0; url=/allure-report/${{ github.repository }}/${{ steps.report_num.number }}/index.html">
<title>Redirecting...</title>
</head>
</html>
EOF
- name: Replace Report URLS
run: |
repository="${{github.repository}}"
repo_name="${repository##*/}"
domain_name="${repository%%/*}"
searchString="\"reportUrl\":\"https://${domain_name}.github.io/${repo_name}"
targetString="\"reportUrl\":\"https://nabinkawan.github.io/allure-report/${repository}"
# - name: Replace Report URLS
# run: |
# repository="${{github.repository}}"
# repo_name="${repository##*/}"
# domain_name="${repository%%/*}"
# searchString="\"reportUrl\":\"https://${domain_name}.github.io/${repo_name}"
# targetString="\"reportUrl\":\"https://nabinkawan.github.io/allure-report/${repository}"

echo "Search string: $searchString"
echo "Target string: $targetString"
# echo "Search string: $searchString"
# echo "Target string: $targetString"

find build/last-history -type f -name "history.json" -exec sed -i "s#${searchString}#${targetString}#g" {} +
# find build/last-history -type f -name "history.json" -exec sed -i "s#${searchString}#${targetString}#g" {} +

- name: Deploy report to Github Pages
uses: JamesIves/github-pages-deploy-action@v4
Expand Down

0 comments on commit 93c5dc4

Please sign in to comment.