Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 18 additions & 31 deletions .github/actions/deploy-reports/action.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
name: "Generate and Deploy Report"
description: "Generates Allure report and deploys to GitHub Pages"
description: "Generates Allure report and uploads to S3"
inputs:
device:
required: true
environment:
required: true
s3-bucket:
required: true
default: 'mavis-end-to-end-test-reports'
report-base-url:
required: true
default: 'https://d118d9btirztbi.cloudfront.net'
runs:
using: composite
steps:
Expand All @@ -19,44 +25,25 @@ runs:
shell: bash
continue-on-error: true

- name: Set GitHub Pages directory
- name: Set S3 prefix
id: set-pages-dir
run: |
branch_ref="${{ github.head_ref || github.ref_name }}"
sanitized_device=$(echo "${{ inputs.device }}" | tr -cd '[:alnum:]_-')
echo "dir=${{ github.head_ref }}/${{ inputs.environment }}/$sanitized_device" >> $GITHUB_OUTPUT
shell: bash

- name: Checkout gh-pages branch
uses: actions/checkout@v6
with:
repository: NHSDigital/manage-vaccinations-in-schools-testing
ref: gh-pages
path: gh-pages
token: ${{ env.GITHUB_TOKEN }}

- name: Replace existing report
run: |
rm -rf gh-pages/${{ steps.set-pages-dir.outputs.dir }}
mkdir -p gh-pages/${{ steps.set-pages-dir.outputs.dir }}
cp -r allure-report/* gh-pages/${{ steps.set-pages-dir.outputs.dir }}
timestamp=$(date -u +"%Y-%m-%d_%H-%M-%S")
echo "dir=$branch_ref/${{ inputs.environment }}/$sanitized_device/$timestamp" >> $GITHUB_OUTPUT
shell: bash

- name: Commit and force-push
- name: Upload report to S3
run: |
cd gh-pages
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout --orphan temp-pages
git add --all
git commit -m "Deployment: $(date +%Y-%m-%d)"
git checkout gh-pages
git pull origin gh-pages --rebase
git reset --hard temp-pages
git push origin gh-pages --force
git branch -D temp-pages
aws s3 sync \
allure-report \
s3://${{ inputs.s3-bucket }}/${{ steps.set-pages-dir.outputs.dir }} \
--delete
shell: bash

- name: Set Job Summary
run: |
echo "Test report URL is https://nhsdigital.github.io/manage-vaccinations-in-schools-testing/${{ steps.set-pages-dir.outputs.dir }}" >> $GITHUB_STEP_SUMMARY
REPORT_URL="${{ inputs.report-base-url }}/${{ steps.set-pages-dir.outputs.dir }}/index.html"
echo "View test report: ${REPORT_URL}" >> "$GITHUB_STEP_SUMMARY"
shell: bash
8 changes: 8 additions & 0 deletions .github/workflows/end-to-end-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ jobs:
test:
permissions:
contents: write
id-token: write

name: End-to-End tests
runs-on: ubuntu-latest
Expand Down Expand Up @@ -237,6 +238,13 @@ jobs:
IMMS_API_KID: ${{ secrets.IMMS_API_KID }}
IMMS_API_PEM: ${{ secrets.IMMS_API_PEM }}

- name: Configure AWS credentials
if: always() && steps.set-variables.outputs.deploy_report == 'true'
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: eu-west-2
role-to-assume: arn:aws:iam::393416225559:role/GitHubAssuranceTestRole

- name: Process reports
if: always() && steps.set-variables.outputs.deploy_report == 'true'
continue-on-error: true
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pull_request_validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
uses: ./.github/workflows/end-to-end-tests.yaml
permissions:
contents: write
id-token: write
with:
cross_service_tests: false
github_ref: ${{ github.ref }}
Expand Down