Files
poimen-memory/.forgejo/workflows/build.yaml
T

62 lines
1.4 KiB
YAML

name: Build and Push
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
REGISTRY: forgejo.riotpiao.com
IMAGE_NAME: rock/poimen-memory
jobs:
test:
name: Test
runs-on: rust
steps:
- uses: actions/checkout@v4
- name: Build
run: cargo build --workspace
- name: Test
run: cargo test --all
build:
name: Build Image
runs-on: rust
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,prefix=
type=raw,value=latest
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max