commit 6d946aa7c8118c0b975802d81af884b327dfaecc Author: Thomas Sauter Date: Wed Oct 22 20:55:49 2025 +0200 first commit diff --git a/.github/workflows/build-monorepo.yaml b/.github/workflows/build-monorepo.yaml new file mode 100644 index 0000000..6e03f12 --- /dev/null +++ b/.github/workflows/build-monorepo.yaml @@ -0,0 +1,68 @@ +name: Build and push +on: + workflow_call: + inputs: + PACKAGE_WRITER_USERNAME: + required: true + type: string + PROJECT_ID: + required: true + type: string +jobs: + build: + name: Build and push + runs-on: ubuntu-latest + steps: + - name: Set current time + uses: https://github.com/gerred/actions/current-time@master + id: current_time + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ vars.IMAGE_BASE_PATH }}/${{ inputs.PROJECT_ID }} + tags: | + type=ref,event=branch,branch=dev,suffix=-{{sha}},optional=true + type=ref,event=branch,branch=dev,value=dev,optional=true + type=match,event=tag,pattern=_v(.*),group=1,prefix=v,optional=true + + - name: Print (debug) Docker meta JSON + uses: https://github.com/actions/github-script@v7 + with: + script: | + const json = JSON.parse(process.env.JSON_STRING); + console.log("------------------------------------------------------------"); + console.log("Docker Meta JSON Output:"); + console.log(""); + console.log(JSON.stringify(json, null, 2)); + console.log(""); + console.log("------------------------------------------------------------"); + env: + JSON_STRING: ${{ steps.meta.outputs.json }} + + - name: Login into gitea registry + uses: docker/login-action@v3 + with: + registry: git.kvant.cloud + username: ${{ inputs.PACKAGE_WRITER_USERNAME }} + password: ${{ secrets.PACKAGE_WRITER_TOKEN }} + + - name: Build container and push to registry + uses: docker/build-push-action@v6 + with: + push: true + file: ./docker/Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + progress=plain + PROJECT_ID=${{ inputs.PROJECT_ID }} + TURBO_TEAM=${{ vars.TURBO_TEAM }} + TURBO_API=${{ vars.TURBO_API }} + TURBO_TOKEN=${{ secrets.TURBO_TOKEN }} + FONTAWESOME_PACKAGE_TOKEN=${{ secrets.FONTAWESOME_PACKAGE_TOKEN }} + IMAGE_TAG=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} + VCS_REF=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} + BUILD_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} diff --git a/.github/workflows/build-standalone.yaml b/.github/workflows/build-standalone.yaml new file mode 100644 index 0000000..44e38b3 --- /dev/null +++ b/.github/workflows/build-standalone.yaml @@ -0,0 +1,61 @@ +name: Build and push +on: + workflow_call: + inputs: + PACKAGE_WRITER_USERNAME: + required: true + type: string +jobs: + build: + name: Build and push + runs-on: ubuntu-latest + steps: + - name: Set current time + uses: https://github.com/gerred/actions/current-time@master + id: current_time + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ vars.IMAGE_PATH }} + tags: | + type=ref,event=branch,branch=dev,suffix=-{{sha}},optional=true + type=ref,event=branch,branch=dev,value=dev,optional=true + type=match,event=tag,pattern=_v(.*),group=1,prefix=v,optional=true + + - name: Print (debug) Docker meta JSON + uses: https://github.com/actions/github-script@v7 + with: + script: | + const json = JSON.parse(process.env.JSON_STRING); + console.log("------------------------------------------------------------"); + console.log("Docker Meta JSON Output:"); + console.log(""); + console.log(JSON.stringify(json, null, 2)); + console.log(""); + console.log("------------------------------------------------------------"); + env: + JSON_STRING: ${{ steps.meta.outputs.json }} + + - name: Login into gitea registry + uses: docker/login-action@v3 + with: + registry: git.kvant.cloud + username: ${{ inputs.PACKAGE_WRITER_USERNAME }} + password: ${{ secrets.PACKAGE_WRITER_TOKEN }} + + - name: Build container and push to registry + uses: docker/build-push-action@v6 + with: + push: true + file: ./docker/Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + progress=plain + FONTAWESOME_PACKAGE_TOKEN=${{ secrets.FONTAWESOME_PACKAGE_TOKEN }} + IMAGE_TAG=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} + VCS_REF=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} + BUILD_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} diff --git a/README.md b/README.md new file mode 100644 index 0000000..d1a0326 --- /dev/null +++ b/README.md @@ -0,0 +1,49 @@ +# Frontend CI/CD + +This repository contains consolidated GitHub (forgejo) pipelines for the frontends we maintain. Its purpose is to provide unified and consistent CI/CD workflows for all recent frontend projects developed and operated within our company, ensuring alignment, quality, and maintainability across setups. + +## Build + +Containers are built using dedicated `Dockerfile`s located in the `/docker` directory within each project repository. After the build, the images are pushed to the registry. + +### `Build Standalone` + +A standard single-repository project with a `package.json` file located at the root, managing dependencies for the entire project. + +##### Inputs + +| Key | Description | Required | +| ------------------------- | ------------------------------- | -------- | +| `PACKAGE_WRITER_USERNAME` | User name of the package writer | ✓ | + +##### Secrets + +| Key | Description | Required | +| --------------------------- | -------------------------------------------------- | -------- | +| `PACKAGE_WRITE_TOKEN` | Accesstoken of the package writer | ✓ | +| `FONTAWESOME_PACKAGE_TOKEN` | Fontawesome Pro library token (Only if fa in use ) | | + +### `Build Monorepo` + +A monorepo project based on Turborepo, with individual projects located under the `/apps/` directory. + +##### Inputs + +| Key | Description | Required | +| ------------------------- | ------------------------------- | -------- | +| `PACKAGE_WRITER_USERNAME` | User name of the package writer | ✓ | +| `PROJECT_ID` | ID of the projcet | ✓ | +| `TURBO_TEAM` | Turbo repo team ID | | +| `TURBO_API` | Turbo repo API | | + +##### Secrets + +| Key | Description | Required | +| --------------------------- | -------------------------------------------------- | -------- | +| `PACKAGE_WRITE_TOKEN` | Access token of the package writer | ✓ | +| `TURBO_TOKEN` | Access token for turbo cache | | +| `FONTAWESOME_PACKAGE_TOKEN` | Fontawesome Pro library token (Only if fa in use ) | | + +## Authors + +- Thomas Sauter, thomas.sauter@phoenix-technologies.ch