69 lines
1.8 KiB
YAML
69 lines
1.8 KiB
YAML
name: CI & Build & Push
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
env:
|
|
REGISTRY: forgejo.riotpiao.com
|
|
REGISTRY_USER: rock
|
|
|
|
jobs:
|
|
test:
|
|
name: Test & Lint
|
|
runs-on: rust
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Cargo test
|
|
run: cargo test -p mem-ingest --lib 2>&1 | tail -50 || true
|
|
|
|
- name: Cargo check
|
|
run: cargo check -p mem-ingest 2>&1 | tail -20 || true
|
|
|
|
build-and-push:
|
|
name: Build & Push Image
|
|
runs-on: rust
|
|
needs: test
|
|
if: github.event_name == 'push'
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Get commit SHA
|
|
id: sha
|
|
run: |
|
|
SHORT_SHA=$(git rev-parse --short HEAD)
|
|
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
|
|
echo "Building image tag: ${{ env.REGISTRY }}/rock/poimen-memory:$SHORT_SHA"
|
|
|
|
- name: Docker login
|
|
env:
|
|
REGISTRY_PAT: ${{ secrets.REGISTRY_PAT }}
|
|
run: |
|
|
echo "$REGISTRY_PAT" | docker login -u ${{ env.REGISTRY_USER }} --password-stdin ${{ env.REGISTRY }}
|
|
|
|
- name: Build Docker image
|
|
run: |
|
|
docker build \
|
|
--tag ${{ env.REGISTRY }}/rock/poimen-memory:${{ steps.sha.outputs.short_sha }} \
|
|
--tag ${{ env.REGISTRY }}/rock/poimen-memory:latest \
|
|
-f Dockerfile \
|
|
.
|
|
echo "✅ Docker image built"
|
|
|
|
- name: Push Docker image
|
|
run: |
|
|
docker push ${{ env.REGISTRY }}/rock/poimen-memory:${{ steps.sha.outputs.short_sha }}
|
|
docker push ${{ env.REGISTRY }}/rock/poimen-memory:latest
|
|
echo "✅ Image pushed to registry"
|
|
|
|
- name: Logout from registry
|
|
if: always()
|
|
run: docker logout ${{ env.REGISTRY }} || true
|