Skip to content

Commit

Permalink
[BREAKING] Change Monorepo tool to Turborepo (#470)
Browse files Browse the repository at this point in the history
* apply turborepo and fix web typescript

* fix reg-scraper typescript

* add packages for api and fix typescript

test release workflow

test release workflow

test release workflow

test release workflow

test release workflow

test release workflow

test release workflow

test release workflow

test release workflow

test release workflow

test release workflow

test release workflow

test release workflow

test release workflow

* add .dockerignore

* fix Dockerfile for web

* fix api

* fix api Dockerfile

* adjust web dockerfile

* fix missing images

* fix web Dockerfile

* partially revert "fix missing images"

This reverts commit c5127c4.

* fix missing images

* fix reg scraper

* fix dev version

* add non build related stuffs to dockerignore

* add more to dockerignore

* rename docker build stages

* reduce line of code

* fix cicd error

* fix cicd

* fix cicd

* Update .github/workflows/release-dev.yaml

---------

Co-authored-by: Nut Pinyo <bomb.np@gmail.com>
Co-authored-by: Suphon Thanakornpakapong <paphonb@gmail.com>
  • Loading branch information
3 people authored Feb 2, 2023
1 parent 61d4cf3 commit 7a1aa4e
Show file tree
Hide file tree
Showing 199 changed files with 9,726 additions and 15,221 deletions.
34 changes: 34 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# build output
dist/
.output/
out/
**/.next/

# dependencies
node_modules/
**/node_modules

# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# environment variables
.env
.env.production

# macOS-specific files
.DS_Store

Dockerfile
**/Dockerfile

# misc
.git
.github
.vscode

# turbo cache
.turbo
**/.turbo
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
root: true,
// This tells ESLint to load the config from the package `eslint-config-custom`
extends: ["custom"],
settings: {
next: {
rootDir: ["apps/*/"],
},
},
};
46 changes: 0 additions & 46 deletions .eslintrc.json

This file was deleted.

144 changes: 144 additions & 0 deletions .github/workflows/deploy-docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: Build and Publish Docker image

on:
workflow_call:
inputs:
packages:
description: Packages to build and publish
required: true
type: string
container-registry:
description: Container registry to push the image to
default: ghcr.io
type: string
image-prefix:
description: Image prefix of the built image
type: string
username:
description: Username for logging in to the container registry
type: string
default: ${{ github.actor }}
password:
description: Password for logging in to the container registry
type: string
default: ${{ github.token }}
target-repository:
description: Target repository for updating deployment declaration
type: string
default: ${{ github.repository }}
target-ref:
description: Target ref for updating deployment declaration
type: string
default: main
target-directory:
description: Target directory for updating deployment declaration
type: string
default: .
push:
description: Enable pushing the image to the container registry
type: boolean
default: false
update:
description: Enable updating deployment declaration in the target repository
type: boolean
default: false

jobs:
build-and-publish-docker-image:
name: Build and Publish Docker image

runs-on: ubuntu-latest

strategy:
matrix:
packages: ${{ fromJson(inputs.packages) }}

outputs:
DOCKERFILE_EXISTS: ${{ steps.check-dockerfile.outputs.DOCKERFILE_EXISTS }}

steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Check if Dockerfile exists
id: check-dockerfile
run: |
if [ ! -f apps/${{ matrix.packages.name }}/Dockerfile ]; then
echo "Dockerfile does not exist"
echo "DOCKERFILE_EXISTS=false" >> $GITHUB_OUTPUT
else
echo "Dockerfile exists"
echo "DOCKERFILE_EXISTS=true" >> $GITHUB_OUTPUT
fi
- name: Set up Docker Buildx
if: steps.check-dockerfile.outputs.DOCKERFILE_EXISTS == 'true'
uses: docker/setup-buildx-action@v2

- name: Login to Container Registry
if: steps.check-dockerfile.outputs.DOCKERFILE_EXISTS == 'true'
uses: docker/login-action@v1
with:
registry: ${{ inputs.container-registry }}
username: ${{ inputs.username || github.actor }}
password: ${{ inputs.password || github.token }}

- name: Build and push Docker image
if: steps.check-dockerfile.outputs.DOCKERFILE_EXISTS == 'true'
uses: docker/build-push-action@v3
with:
context: .
file: apps/${{ env.APP_NAME }}/Dockerfile
tags: |
${{ inputs.container-registry }}/${{ inputs.image-prefix }}/${{ env.APP_NAME }}:latest
${{ inputs.container-registry }}/${{ inputs.image-prefix }}/${{ env.APP_NAME }}:${{ env.VERSION }}
push: ${{ inputs.push }}
env:
APP_NAME: ${{ matrix.packages.name }}
VERSION: ${{ matrix.packages.version }}

- name: Show Docker image
if: steps.check-dockerfile.outputs.DOCKERFILE_EXISTS == 'true'
run: docker images

update-deployment-declaration:
name: Update deployment declaration

if: ${{ inputs.update && needs.build-and-publish-docker-image.outputs.DOCKERFILE_EXISTS == 'true' }}

needs:
- build-and-publish-docker-image

runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
repository: ${{ inputs.target-repository }}
ref: ${{ inputs.target-ref }}

- name: Update publishPackages version in YAML file
run: |
for row in $(echo "$PACKAGES" | jq -r '.[] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
NAME=$(_jq '.name')
VERSION=$(_jq '.version')
OLD_VERSION=${{ inputs.container-registry }}\/${{ inputs.image-prefix }}\/$NAME:.*
NEW_VERSION=${{ inputs.container-registry }}\/${{ inputs.image-prefix }}\/$NAME:$VERSION
find ./${{ inputs.target-directory }} -type f -exec sed -i -e "s|$OLD_VERSION|$NEW_VERSION|g" {} \;
echo "${NAME}:${VERSION} is updated"
done
env:
PACKAGES: ${{ inputs.packages }}

- name: Show git status
run: git status

- name: Open Pull Request to the target repository
uses: peter-evans/create-pull-request@v4
with:
title: Update Package versions
commit-message: Update Package versions
156 changes: 0 additions & 156 deletions .github/workflows/deploy.yaml

This file was deleted.

Loading

0 comments on commit 7a1aa4e

Please sign in to comment.