fix(tests) tests pass after merge #35
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI Pipeline | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.set_version.outputs.version }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20.x" | |
- name: Install dependencies | |
run: npm ci | |
- name: Run tests | |
run: | | |
npx playwright install --with-deps chromium | |
npm run test:coverage | |
- name: set version | |
id: set_version | |
run: | | |
version=$(date +'%Y%m%d.%H%M%S') | |
echo "version=$version" >> "$GITHUB_OUTPUT" | |
printf '{"version": "%s" }' "$version" > public/version.json | |
- name: Update coverage | |
run: | | |
coverage_pct=$(grep -o '"pct":[0-9.]*' coverage/coverage-summary.json | head -n 1 | cut -d ':' -f 2) | |
color=$(echo "$coverage_pct < 80" | bc -l | awk '{if ($1) print "yellow"; else print "green"}') | |
curl https://img.shields.io/badge/Coverage-$coverage_pct%25-$color -o coverageBadge.svg | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
git add . | |
if git diff --staged --quiet; then | |
echo "No changes to commit" | |
else | |
git commit -m "Update coverage badge to $coverage_pct%" | |
git push | |
fi | |
- name: Build | |
run: | | |
npm run build | |
- name: Update dist artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: package | |
path: dist/ | |
deploy: | |
needs: build | |
permissions: | |
id-token: write | |
runs-on: ubuntu-latest | |
env: | |
version: ${{needs.build.outputs.version}} | |
steps: | |
- name: Create OIDC token to AWS | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
audience: sts.amazonaws.com | |
aws-region: us-east-1 | |
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT }}:role/${{ secrets.CI_IAM_ROLE }} | |
- name: Download dist artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: package | |
path: dist/ | |
- name: Push to AWS S3 | |
run: | | |
echo Deploying $version | |
aws s3 cp dist s3://${{ secrets.APP_BUCKET }} --recursive | |
aws cloudfront create-invalidation --distribution-id ${{ secrets.DISTRIBUTION_ID }} --paths "/*" | |
release: | |
needs: | |
- build | |
- deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create Release | |
uses: ncipollo/release-action@v1 | |
env: | |
version: ${{needs.build.outputs.version}} | |
with: | |
tag: version-${{ env.version }} | |
name: Version ${{ env.version }} | |
body: | | |
## 🚀 Changes | |
${{ github.event.head_commit.message }} | |
**commit**: ${{ github.sha }} |