Skip to content

chore(deps): update dependency @types/supertest to v6.0.2 #82

chore(deps): update dependency @types/supertest to v6.0.2

chore(deps): update dependency @types/supertest to v6.0.2 #82

Workflow file for this run

name: Deploy
on:
push:
branches:
- main
tags:
- v*
pull_request:
workflow_dispatch:
jobs:
changes:
runs-on: ubuntu-latest
outputs:
gateway-service: ${{ steps.filter.outputs.gateway-service }}
product-service: ${{ steps.filter.outputs.product-service }}
storefront: ${{ steps.filter.outputs.storefront }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
gateway-service:
- 'apps/gateway-service/**'
- 'package.json'
- 'packages/**'
product-service:
- 'apps/product-service/**'
- 'package.json'
- 'packages/**'
storefront:
- 'apps/storefront/**'
- 'package.json'
- 'packages/**'
push:
needs: changes
strategy:
matrix:
service:
- name: gateway-service
path: apps/gateway-service
package: "@cavaliercommerce/gateway-service"
dockerfile: apps/gateway-service/Dockerfile
- name: product-service
path: apps/product-service
package: "@cavaliercommerce/product-service"
dockerfile: apps/product-service/Dockerfile
- name: storefront
path: apps/storefront
package: "@cavaliercommerce/storefront"
dockerfile: apps/storefront/Dockerfile
runs-on: ubuntu-latest
name: Deployment of ${{ matrix.service.name }}
permissions:
packages: write
contents: read
steps:
- name: Check if should run
id: should-run
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" || "${{ needs.changes.outputs[matrix.service.name] }}" == "true" ]]; then
echo "run=true" >> $GITHUB_OUTPUT
else
echo "run=false" >> $GITHUB_OUTPUT
fi
- uses: actions/checkout@v4
if: steps.should-run.outputs.run == 'true'
- name: Cache turbo build setup
if: steps.should-run.outputs.run == 'true'
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- uses: pnpm/action-setup@v4
if: steps.should-run.outputs.run == 'true'
with:
version: 9.0.0
- run: echo "node_version=$(cat .github/nodejs.version)" >> $GITHUB_ENV
if: steps.should-run.outputs.run == 'true'
- name: "Use node ${{ env.node_version }}"
if: steps.should-run.outputs.run == 'true'
uses: actions/setup-node@v3
with:
node-version: "${{ env.node_version }}"
cache: "pnpm"
- name: Install dependencies
if: steps.should-run.outputs.run == 'true'
run: pnpm install && pnpm add -g [email protected]
- name: Generate Prisma types
if: steps.should-run.outputs.run == 'true' && matrix.service.name != 'storefront'
run: pnpm dlx [email protected] generate --schema apps/${{ matrix.service.name }}/prisma/schema.prisma
- name: Run tests
if: steps.should-run.outputs.run == 'true'
run: pnpm test --filter ${{ matrix.service.package }}
- name: Build image
if: steps.should-run.outputs.run == 'true'
run: docker build . --file ${{ matrix.service.dockerfile }} --tag ${{ matrix.service.name }} --label "runnumber=${GITHUB_RUN_ID}"
- name: Log in to registry
if: steps.should-run.outputs.run == 'true'
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image
if: steps.should-run.outputs.run == 'true'
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/${{ matrix.service.name }}
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag ${{ matrix.service.name }} $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
- name: Update service with new image
if: steps.should-run.outputs.run == 'true'
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
port: ${{ secrets.SSH_PORT }}
script: cd ~/cavalier && docker service update --with-registry-auth --force --image=ghcr.io/cavaliercommerce/${{ matrix.service.name }}:latest cavalier_${{ matrix.service.name }}