Skip to content

Commit

Permalink
refactor: 👷 refactor ci build system
Browse files Browse the repository at this point in the history
  • Loading branch information
thomashbrnrd committed Oct 8, 2024
1 parent 70e5e6f commit 86fd4a2
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 74 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build

on:
workflow_call:
inputs:
image:
required: true
type: string
context:
required: true
type: string
outputs:
tags:
type: string
jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.meta.outputs.tags }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ inputs.image }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ${{ inputs.context }}
push: true
pull: true
tags: ${{ steps.meta.outputs.tags }}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Clean registry

on:
pull_request:
types:
Expand Down
73 changes: 26 additions & 47 deletions .github/workflows/main-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Main CI

on:
pull_request:
types: [opened, reopened, synchronize]
Expand All @@ -24,55 +25,17 @@ jobs:

build-backend:
name: Build Backend
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.meta.outputs.tags }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/dnum-mi/basegun/basegun-backend
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./backend
push: true
pull: true
tags: ${{ steps.meta.outputs.tags }}
uses: ./.github/workflows/build.yml
with:
image: ghcr.io/dnum-mi/basegun/basegun-backend
context: ./backend

build-frontend:
name: Build Frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/dnum-mi/basegun/basegun-frontend
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./frontend
push: true
pull: true
tags: ${{ steps.meta.outputs.tags }}
uses: ./.github/workflows/build.yml
with:
image: ghcr.io/dnum-mi/basegun/basegun-frontend
context: ./frontend

test-backend:
name: Test Backend
Expand Down Expand Up @@ -118,4 +81,20 @@ jobs:
test-e2e:
name: Run E2E tests
needs: [build-backend, build-frontend]
uses: ./.github/workflows/test-e2e.yml
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Start stack using docker compose
run: docker compose -f docker-compose.yml -f docker-compose.override.ci.yml up -d
- name: Cypress run
uses: cypress-io/github-action@v6
with:
working-directory: ./frontend
command: npm run test:e2e-ci
- name: Send artifacts
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: cypress-screenshots
path: |
./frontend/cypress/screenshots/
27 changes: 0 additions & 27 deletions .github/workflows/test-e2e.yml

This file was deleted.

0 comments on commit 86fd4a2

Please sign in to comment.