Skip to content

14 - Working with Artifacts #3

14 - Working with Artifacts

14 - Working with Artifacts #3

Workflow file for this run

name: 14 - Working with Artifacts
on:
workflow_dispatch:
env:
build-artifact-key: app-${{ github.sha }}
test-coverage-key: test-coverage-${{ github.sha }}
jobs:
test-build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: 14-artifacts/react-app
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: Download cached dependencies
uses: actions/cache@v3
id: cache
with:
path: 14-artifacts/react-app/node_modules
key: deps-node-modules-${{ hashFiles('14-artifacts/react-app/package-lock.json') }}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Unit tests
run: npm run test -- --coverage
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: ${{ env.test-coverage-key }}
path: 14-artifacts/react-app/coverage
- name: Build code
run: npm run build
- name: Upload build files
uses: actions/upload-artifact@v3
with:
name: ${{ env.build-artifact-key }}
path: 14-artifacts/react-app/build
deploy:
runs-on: ubuntu-latest
needs: test-build
steps:
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.build-artifact-key }}
path: build
- name: Show folder structure
run: ls -R