refactor(s3): use s3 #744
Workflow file for this run
This file contains hidden or 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 | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| tags: | |
| - "v*" | |
| pull_request: | |
| branches: | |
| - 'main' | |
| concurrency: | |
| group: registry-push-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| runtime: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| runtime_built: 'true' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Fetch default branch | |
| run: git fetch origin main | |
| - name: Check if dependencies changed | |
| id: dep_check | |
| run: | | |
| if git diff --name-only origin/main | grep -E 'package.json|pnpm-lock.yaml|pnpm-workspace.yaml|runtime.Dockerfile'; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Docker meta (runtime) | |
| if: steps.dep_check.outputs.changed == 'true' | |
| id: meta_runtime | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ghcr.io/import-ai/omnibox-backend-runtime | |
| tags: | | |
| type=sha | |
| type=raw,value=latest | |
| - name: Set up QEMU | |
| if: steps.dep_check.outputs.changed == 'true' | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| if: steps.dep_check.outputs.changed == 'true' | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to ghcr.io Registry | |
| if: steps.dep_check.outputs.changed == 'true' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push runtime image | |
| if: steps.dep_check.outputs.changed == 'true' | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: runtime.Dockerfile | |
| push: true | |
| tags: ${{ steps.meta_runtime.outputs.tags }} | |
| labels: ${{ steps.meta_runtime.outputs.labels }} | |
| platforms: | | |
| linux/amd64 | |
| linux/arm64 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| test: | |
| runs-on: ubuntu-latest | |
| needs: [ runtime ] | |
| container: | |
| image: ghcr.io/import-ai/omnibox-backend-runtime:latest | |
| credentials: | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Get version identifier | |
| id: get_version | |
| run: | | |
| if [ "${GITHUB_REF#refs/tags/}" != "$GITHUB_REF" ]; then | |
| echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| else | |
| echo "version=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Prepare .env | |
| run: cp example.env .env | |
| - name: Run tests | |
| run: pnpm test:e2e --coverage | |
| env: | |
| OBB_POSTGRES_URL: postgres://omnibox:omnibox@postgres:5432/omnibox | |
| OBB_MINIO_URL: http://username:password@minio:9000/omnibox | |
| OBB_LOG_LEVELS: "" | |
| - name: Print coverage report | |
| run: | | |
| bash test/coverage_report.sh "coverage/lcov-report/index.html" "${GITHUB_STEP_SUMMARY}" | |
| mv coverage coverage-report-${{ steps.get_version.outputs.version }} | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report-${{ steps.get_version.outputs.version }} | |
| path: coverage-report-${{ steps.get_version.outputs.version }} | |
| app: | |
| runs-on: ubuntu-latest | |
| needs: [ test ] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Docker meta (app) | |
| id: meta_app | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ghcr.io/import-ai/omnibox-backend | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=sha | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to ghcr.io Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push app image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: Dockerfile | |
| push: true | |
| tags: ${{ steps.meta_app.outputs.tags }} | |
| labels: ${{ steps.meta_app.outputs.labels }} | |
| platforms: | | |
| linux/amd64 | |
| linux/arm64 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| webhook: | |
| runs-on: ubuntu-latest | |
| needs: [ app ] | |
| steps: | |
| - name: TEST push webhook | |
| if: github.event_name == 'push' | |
| run: | | |
| curl "${{ secrets.DEV_WEBHOOK_URL }}/test?module=backend&pr=${{ github.ref_name }}&commit=${GITHUB_SHA}&tag=sha-${GITHUB_SHA::7}" -H "Authorization: Bearer ${{ secrets.DEV_WEBHOOK_API_KEY }}" | |
| - name: TEST pull request webhook | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| curl "${{ secrets.DEV_WEBHOOK_URL }}/test?module=backend&pr=pr-${{ github.event.number }}&commit=${{ github.event.pull_request.head.sha }}&tag=sha-${GITHUB_SHA::7}" -H "Authorization: Bearer ${{ secrets.DEV_WEBHOOK_API_KEY }}" |