GitHub Actions

Reusable Workflows and Reporting

Project Status Meeting 5

Overview

In this fifth project status meeting, Alice and her team discuss a new reporting requirement: collecting unit-test results and code-coverage metrics, then storing them in a durable location. Since GitHub Actions limits artifact retention duration (default 90 days) and size, the team proposes using an AWS S3 bucket for long-term storage.

Note

By default, GitHub Actions artifacts expire after 90 days. AWS S3 provides virtually unlimited storage with configurable lifecycle rules.

Objectives

  • Aggregate test reports and coverage files.
  • Upload artifacts automatically to S3 at the end of each workflow run.
  • Ensure security and cost-efficiency by applying proper lifecycle policies.

Proposed Workflow Job

  1. Run tests and generate artifacts.
  2. Cache or publish intermediate results.
  3. Upload final reports to S3.
name: CI with S3 Archiving

on:
  push:
    branches: [ main ]

jobs:
  test-and-coverage:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Run unit tests
        run: |
          npm install
          npm test
        continue-on-error: false

      - name: Generate coverage report
        run: npm run coverage

      - name: Upload reports as artifacts
        uses: actions/upload-artifact@v3
        with:
          name: test-results
          path: |
            ./reports/test-results.xml
            ./coverage

  upload-to-s3:
    needs: test-and-coverage
    runs-on: ubuntu-latest
    steps:
      - name: Download artifacts
        uses: actions/download-artifact@v3
        with:
          name: test-results
          path: ./artifacts

      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@v2
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1

      - name: Upload to S3
        run: |
          aws s3 cp ./artifacts s3://my-report-bucket/${{ github.run_id }}/ \
            --recursive --acl private

Warning

Always store AWS credentials in GitHub Secrets. Never hard-code them in your workflow files.

Benefits

  • Centralized, long-term storage for all test artifacts
  • Fine-grained lifecycle policies (e.g., transition to Glacier)
  • Cost control through S3 storage classes

Tool Comparison

ResourceUse CaseAction Example
GitHub Actions ArtifactsShort-term CI/CD resultsactions/upload-artifact
AWS S3 BucketDurable, long-term storageaws s3 cp
AWS S3 Lifecycle PoliciesAutomated data transition to lower-cost tiersDefine in S3 console or via Terraform
aws-actions/configure-aws-credentialsSimplify AWS authentication in workflowsuses: aws-actions/configure-aws-credentials@v2

Watch Video

Watch video content

Previous
Step 4 Using Outputs in Reusable Workflow