Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Ebubeker committed Sep 7, 2023
2 parents 867f6b9 + c3ee89d commit aa1b4bc
Show file tree
Hide file tree
Showing 23 changed files with 434 additions and 975 deletions.
50 changes: 50 additions & 0 deletions .github/actions/pnpm-cache-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
########################################################################################
# "client-cache-build" composite action for client build #
#--------------------------------------------------------------------------------------#
# #
# Usage in workflows steps: #
# #
# - name: 🏗️ Monorepo build #
# uses: ./.github/actions/client-cache-build #
# with: #
# cwd: ${{ github.workspace }}/apps/goat # (default = '.') #
########################################################################################

name: "Cache production build binaries"
description: "Cache or restore if necessary"
author: "Plan4Better GmbH"

inputs:
cwd:
description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()"
required: false
default: '.'
node_version:
description: "Node version to use"
required: false
default: v18.x

runs:
using: "composite"
steps:
- name: Cache production build
uses: actions/cache@v3
id: cache-build
env:
cache-name: prod-build
key-1: ${{ inputs.node_version }}-${{ hashFiles('${{ inputs.cwd }}/pnpm-lock.yaml') }}
key-2: ${{ hashFiles('${{ inputs.cwd }}/apps/**/**.[jt]s', '${{ inputs.cwd }}/apps/**/**.[jt]sx', '${{ inputs.cwd }}/packages/**/**.[jt]s', '${{ inputs.cwd }}/packages/**/**.[jt]sx', '!**/node_modules') }}
key-3: ${{ github.event.pull_request.number || github.ref }}
# Ensures production-build.yml will always be fresh
key-4: ${{ github.sha }}
with:
path: |
${{ github.workspace }}/app/client/apps/goat/.next
**/.turbo/**
**/dist/**
key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.key-1 }}-${{ env.key-2 }}-${{ env.key-3 }}-${{ env.key-4 }}

- run: pnpm run build
working-directory: ${{ inputs.cwd }}
if: steps.cache-build.outputs.cache-hit != 'true'
shell: bash
2 changes: 1 addition & 1 deletion .github/workflows/nextjs-bundle-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
cwd: ${{ github.workspace }}

- name: 🏗️ Build
uses: goat-community/.github/.github/actions/nextjs-turborepo-pnpm-cache-build
uses: ./.github/actions/pnpm-cache-build
with:
cwd: ${{ github.workspace }}

Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ concurrency:


jobs:

pr-base:
name: pr-base
uses: "goat-community/.github/.github/workflows/reusable-pr-base.yml@main"
permissions:
contents: none
issues: read
pull-requests: write
secrets: inherit

typecheck:
name: typecheck
uses: ./.github/workflows/check-types.yml
Expand All @@ -35,7 +45,6 @@ jobs:
uses: ./.github/workflows/lint.yml
secrets: inherit

# todo: test run

build:
name: build
Expand All @@ -48,12 +57,6 @@ jobs:
uses: ./.github/workflows/nextjs-bundle-analysis.yml
secrets: inherit

release-docker-build:
name: docker-build
needs: [build, analyze]
uses: ./.github/workflows/release.yml
secrets: inherit

required:
needs: [lint, typecheck, build]
if: always()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/production-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ jobs:
cwd: ${{ github.workspace }}

- name: 🏗️ Monorepo build
uses: goat-community/.github/.github/actions/nextjs-turborepo-pnpm-cache-build
uses: ./.github/actions/pnpm-cache-build
with:
cwd: ${{ github.workspace }}
17 changes: 0 additions & 17 deletions .github/workflows/push.yml

This file was deleted.

69 changes: 22 additions & 47 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,29 @@
name: "Release"

on:
workflow_call:
push:
branches: [main]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:

release-goat:
name: release-goat
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout
uses: actions/checkout@v4

- name: 🐳 Setup Docker Buildx
uses: docker/setup-buildx-action@v1

- name: 🐳 Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: 🐳 Docker meta
id: docker_meta
uses: docker/metadata-action@v4.6.0
with:
images: goatcommunity/goat-frontend
flavor: |
latest=auto
tags: |
type=raw,value={{sha}}
type=ref,event=tag,priority=200
type=raw,value=latest,enable=${{startsWith(github.ref, 'refs/tags/v' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) )}},priority=100,
type=ref,event=pr,priority=100
- name: 🐳 Build docker image
uses: docker/build-push-action@v4
with:
context: ${{ github.workspace }}
file: ${{ github.workspace }}/apps/goat/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: 🐳 Find the primary image tag we just pushed, and output it
id: image-tag
run: |
echo "image-tag=${{ steps.docker_meta.outputs.version }}" >> $GITHUB_OUTPUT
release-docker:
name: release
uses: "goat-community/.github/.github/workflows/reusable-docker-build.yml@main"
permissions:
contents: read
packages: write
pull-requests: write
secrets:
dockerhub-username: ${{ secrets.DOCKER_USERNAME }}
dockerhub-token: ${{ secrets.DOCKER_PASSWORD }}
with:
dockerhub-enable: true
ghcr-enable: false
push: ${{ github.event_name != 'pull_request' }}
file: ${{ github.workspace }}/apps/goat/Dockerfile
image-names: |
goatcommunity/goat-frontend
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

.env

# dependencies
node_modules
.pnp
Expand Down Expand Up @@ -41,4 +39,4 @@ yarn-error.log*
# others
build_keycloak
storybook-static
*.jar
*.jar
Loading

0 comments on commit aa1b4bc

Please sign in to comment.