add description #76
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test and Build | |
on: | |
pull_request: | |
push: | |
branches: [main] | |
tags: | |
- "*" | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
lint_ts: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
- name: Cache typeshare-cli | |
id: cache-typeshare-cli | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cargo/bin/typeshare | |
key: ${{ runner.os }}-typeshare-cli-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-typeshare-cli- | |
- name: Install Rust Chain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
if: steps.cache-typeshare-cli.outputs.cache-hit != 'true' | |
- name: Install type generator | |
if: steps.cache-typeshare-cli.outputs.cache-hit != 'true' | |
run: cargo install typeshare-cli --force | |
- name: Generate Bindings | |
run: typeshare ./backend --lang=typescript --output-file=frontend/bindings.ts | |
- name: Cache node modules | |
id: cache-nodemodules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Install Dependencies | |
if: steps.cache-nodemodules.outputs.cache-hit != 'true' | |
run: npm i | |
- name: lint | |
run: npx eslint . | |
- name: build | |
run: npm run build | |
format_ts: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
- name: Cache node modules | |
id: cache-nodemodules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Install Dependencies | |
if: steps.cache-nodemodules.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: format | |
run: npx prettier backend/ --check | |
format_rs: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
components: rustfmt | |
- name: Rustfmt Check | |
uses: actions-rust-lang/rustfmt@v1 | |
build_and_push: | |
name: build_and_push | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
needs: | |
- lint_ts | |
- format_ts | |
- format_rs | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
env: | |
DOCKER_METADATA_PR_HEAD_SHA: true | |
with: | |
images: | | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} | |
tags: | | |
type=raw,value=edge,enable=${{ github.ref == 'refs/heads/main' }} | |
type=sha,format=short | |
type=semver,pattern={{raw}} | |
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
tags: ${{ steps.meta.outputs.tags }} | |
platforms: linux/amd64,linux/arm64/v8 |