Skip to content

feat: set up blob propagation mechanism #806

feat: set up blob propagation mechanism

feat: set up blob propagation mechanism #806

Workflow file for this run

name: Continuous Integration (build, docker, deploy)
on:
pull_request:
branches: ["*"]
push:
branches: ["master", "next"]
merge_group:
# You can leverage Vercel Remote Caching with Turbo to speed up your builds
# @link https://turborepo.org/docs/core-concepts/remote-caching#remote-caching-on-vercel-builds
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
jobs:
build-lint-test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
ports:
# Maps port 6379 on service container to the host
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup pnpm
uses: pnpm/action-setup@v2.2.4
- name: Setup Node 20
uses: actions/setup-node@v3
with:
node-version: 20
- name: Setup GCS emulator
uses: fsouza/fake-gcs-action@v0.4.1
with:
version: "1.37.2"
backend: memory
scheme: http
data: packages/test/src/fixtures/storage
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install deps (with cache)
run: pnpm install
- name: Generate Prisma Client
run: pnpm turbo db:generate
- name: Test migrations
run: pnpm prisma migrate deploy --schema packages/db/prisma/schema.prisma
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/blobscan_ci?schema=public
- name: Build, lint and type-check
run: pnpm turbo build lint type-check
env:
SKIP_ENV_VALIDATION: true
- name: Tests
run: pnpm test
env:
POSTGRES_STORAGE_ENABLED: true
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/blobscan_ci
docker:
runs-on: ubuntu-latest
needs: build-lint-test
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: blossomlabs/blobscan
tags: |
type=ref,event=branch
type=raw,value=latest,enable=${{ github.ref_name == 'next' }}
type=raw,value=stable,enable=${{ github.ref_name == 'master' }}
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set Github ENV variables
shell: bash
run: |
echo "BUILD_TIMESTAMP=$(date '+%F %H:%M:%S')" >> $GITHUB_ENV
echo "GIT_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILD_TIMESTAMP=${{ env.BUILD_TIMESTAMP }}
GIT_COMMIT=${{ env.GIT_COMMIT }}
deploy_staging:
if: github.ref_name == 'next'
name: Deploy blobscan api (staging)
runs-on: ubuntu-latest
environment:
name: staging
url: https://staging.blobscan.com
needs: docker
steps:
- uses: appleboy/ssh-action@v0.0.7
with:
host: ${{ secrets.SSH_HOST }}
username: deploy
port: ${{ secrets.SSH_PORT }}
key: ${{ secrets.SSH_KEY }}
script: ./deploy-blobscan.sh
deploy_prod:
if: github.ref_name == 'master'
name: Deploy blobscan api (prod)
runs-on: ubuntu-latest
environment:
name: production
url: https://blobscan.com
needs: docker
steps:
- uses: appleboy/ssh-action@v0.0.7
with:
host: ${{ secrets.SSH_HOST }}
username: deploy
port: ${{ secrets.SSH_PORT }}
key: ${{ secrets.SSH_KEY }}
script: ./deploy-blobscan.sh