Skip to content
Open
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
122 changes: 122 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

env:
IMAGE_NAME: "cachecash"
PROJECT_ID: "hyle-413414"
AR_REPO_LOCATION: "europe-west3"
AR_URL: "europe-west3-docker.pkg.dev/hyle-413414/hyle-docker"
SERVICE_ACCOUNT: "github-actions-service-account@hyle-413414.iam.gserviceaccount.com"
WORKLOAD_IDENTITY_PROVIDER: ""

jobs:
rust:
name: Rust Checks
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt

- name: Cache cargo build artifacts
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true

- name: Run cargo fmt
run: cargo fmt --all -- --check


- name: Run cargo test
run: cargo test --workspace --all-targets

frontend:
name: Frontend Build
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Install dependencies
working-directory: front
run: bun install --frozen-lockfile

- name: Build frontend
working-directory: front
run: bun run build

docker:
name: Docker Build
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
strategy:
matrix:
suffix:
- server
- ui
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.AR_URL }}/${{ env.IMAGE_NAME }}-${{ matrix.suffix }}
ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}-${{ matrix.suffix }}
tags: |
type=sha
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest,enable={{is_default_branch}}

- name: Docker Auth (Google Artifact Registry)
if: github.event_name == 'push'
uses: docker/login-action@v3
with:
username: _json_key
password: ${{ secrets.GOOGLE_CREDENTIALS }}
registry: "${{ env.AR_REPO_LOCATION }}-docker.pkg.dev"

- name: Login to GitHub Container Registry
if: github.event_name == 'push'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push ${{ matrix.suffix }} image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.${{ matrix.suffix }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ github.event_name == 'push' }}
103 changes: 103 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Docker

on:
push:
branches:
- "releases/**"
tags:
- "*"
workflow_dispatch:
inputs:
build_server:
description: "Build server image"
type: boolean
default: true
build_ui:
description: "Build ui image"
type: boolean
default: true

env:
IMAGE_NAME: "cachecash"
PROJECT_ID: "hyle-413414"
AR_REPO_LOCATION: "europe-west3"
AR_URL: "europe-west3-docker.pkg.dev/hyle-413414/hyle-docker"
SERVICE_ACCOUNT: "github-actions-service-account@hyle-413414.iam.gserviceaccount.com"
WORKLOAD_IDENTITY_PROVIDER: ""

jobs:
build_and_push:
permissions:
contents: "read"
id-token: "write"
packages: "write"

runs-on: ubuntu-latest
strategy:
matrix:
suffix:
- server
- ui

steps:
- name: Checkout
if: |
github.event_name == 'push' ||
(matrix.suffix == 'server' && inputs.build_server) ||
(matrix.suffix == 'ui' && inputs.build_ui)
uses: actions/checkout@v4

- name: Docker meta
if: |
github.event_name == 'push' ||
(matrix.suffix == 'server' && inputs.build_server) ||
(matrix.suffix == 'ui' && inputs.build_ui)
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.AR_URL }}/${{ env.IMAGE_NAME }}-${{ matrix.suffix }}
ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}-${{ matrix.suffix }}
tags: |
type=sha
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest,enable={{is_default_branch}}

- name: Docker Auth (Google Artifact Registry)
if: |
github.event_name == 'push' ||
(matrix.suffix == 'server' && inputs.build_server) ||
(matrix.suffix == 'ui' && inputs.build_ui)
uses: docker/login-action@v3
with:
username: _json_key
password: ${{ secrets.GOOGLE_CREDENTIALS }}
registry: "${{ env.AR_REPO_LOCATION }}-docker.pkg.dev"

- name: Login to GitHub Container Registry
if: |
github.event_name == 'push' ||
(matrix.suffix == 'server' && inputs.build_server) ||
(matrix.suffix == 'ui' && inputs.build_ui)
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
if: |
github.event_name == 'push' ||
(matrix.suffix == 'server' && inputs.build_server) ||
(matrix.suffix == 'ui' && inputs.build_ui)
uses: docker/build-push-action@v6
with:
push: true
context: .
file: Dockerfile.${{ matrix.suffix }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
29 changes: 3 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading