Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: _BUILD

on:
workflow_call:
inputs:
artifact-name:
description: Name for the uploaded dist artifact
required: true
type: string
upload-artifact:
description: Whether to upload the dist artifact
required: false
type: boolean
default: true

permissions: {}

jobs:
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
steps:
- name: Harden Runner
uses: step-security/harden-runner@05e31511f85b41b11d1cf0ef85d0992719546e2c # v2.21.0
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@v7
with:
persist-credentials: false

- name: Setup pnpm
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
with:
run_install: false

- name: Setup Node
uses: actions/setup-node@v7
with:
node-version-file: .node-version
cache: 'pnpm'

- name: Install dependencies
run: |
pnpm i --frozen-lockfile

- name: Run lint
run: |
pnpm run lint --no-fix

- name: Run type check
if: ${{ !cancelled() }}
run: |
pnpm run type-check

- name: Run tests
if: ${{ !cancelled() }}
run: |
pnpm run test:unit

- name: Run circular references check
if: ${{ !cancelled() }}
run: |
pnpm run circular-check

- name: Build
run: |
pnpm run build

- name: Upload dist
if: inputs.upload-artifact
uses: actions/upload-artifact@v7
with:
name: ${{ inputs.artifact-name }}
path: ./dist
retention-days: 7
101 changes: 101 additions & 0 deletions .github/workflows/_publish-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: _PUBLISH DOCKER

on:
workflow_call:
inputs:
artifact-name:
description: Name of the dist artifact to publish
required: true
type: string

permissions: {}

jobs:
publish-docker:
name: Publish ${{ matrix.type }} Image
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
- type: Docker
image-name: ${{ github.repository }}
base-image: nginx:alpine-slim
port: 80
- type: Docker Unprivileged
image-name: ${{ github.repository }}-unprivileged
base-image: nginxinc/nginx-unprivileged:alpine-slim
port: 8080
permissions:
id-token: write
contents: read
attestations: write
packages: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@05e31511f85b41b11d1cf0ef85d0992719546e2c # v2.21.0
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@v7
with:
persist-credentials: false

- name: Download dist
uses: actions/download-artifact@v8
with:
name: ${{ inputs.artifact-name }}
path: ./dist

- name: Prepare Docker image metadata
id: docker_meta
uses: docker/metadata-action@v6
with:
images: |
ghcr.io/${{ matrix.image-name }}
tags: |
type=semver,pattern={{raw}}
type=sha,format=long
type=raw,value=latest-develop,enable=${{ github.ref == 'refs/heads/develop' }}
type=raw,value=latest-master,enable=${{ github.ref == 'refs/heads/master' }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Log in to the Container registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
id: docker_push
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8
build-args: |
BASE_IMAGE=${{ matrix.base-image }}
PORT=${{ matrix.port }}
push: true
sbom: true
provenance: true
cache-from: type=gha,scope=${{ matrix.type }}
cache-to: type=gha,mode=min,scope=${{ matrix.type }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
annotations: ${{ steps.docker_meta.outputs.annotations }}

- name: Attest Docker image
uses: actions/attest-build-provenance@v4
with:
subject-name: ghcr.io/${{ matrix.image-name }}
subject-digest: ${{ steps.docker_push.outputs.digest }}
push-to-registry: true
Loading
Loading