2026-08-23 00:01:30 -07:00
|
|
|
name: Build and Push
|
|
|
|
|
|
|
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
|
branches: [main]
|
|
|
|
|
pull_request:
|
|
|
|
|
branches: [main]
|
|
|
|
|
|
|
|
|
|
env:
|
|
|
|
|
REGISTRY: forgejo.riotpiao.com
|
2026-08-23 16:05:18 -07:00
|
|
|
IMAGE: forgejo.riotpiao.com/rock/poimen-memory
|
2026-08-23 00:01:30 -07:00
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
test:
|
|
|
|
|
name: Test
|
2026-08-28 15:52:25 -07:00
|
|
|
runs-on: rust
|
2026-08-28 15:46:27 -07:00
|
|
|
container: rust:1-bookworm
|
2026-08-23 00:01:30 -07:00
|
|
|
steps:
|
2026-08-28 15:46:27 -07:00
|
|
|
- name: Install node (required by JS-based actions)
|
|
|
|
|
run: apt-get update && apt-get install -y --no-install-recommends nodejs
|
|
|
|
|
|
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
|
|
|
|
|
|
- name: Cache cargo
|
|
|
|
|
uses: actions/cache@v4
|
|
|
|
|
with:
|
|
|
|
|
path: |
|
|
|
|
|
~/.cargo/registry
|
|
|
|
|
~/.cargo/git
|
|
|
|
|
target
|
|
|
|
|
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
|
restore-keys: |
|
|
|
|
|
cargo-${{ runner.os }}-
|
2026-08-23 17:35:45 -07:00
|
|
|
|
2026-08-23 16:05:18 -07:00
|
|
|
- name: Run tests
|
2026-08-23 00:01:30 -07:00
|
|
|
run: cargo test --all
|
|
|
|
|
|
2026-08-23 16:05:18 -07:00
|
|
|
build:
|
|
|
|
|
name: Build and push image
|
2026-08-28 15:52:25 -07:00
|
|
|
runs-on: golang
|
2026-08-23 00:01:30 -07:00
|
|
|
needs: test
|
|
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
2026-08-28 15:52:25 -07:00
|
|
|
container:
|
|
|
|
|
image: docker:27-cli
|
|
|
|
|
volumes:
|
|
|
|
|
- /docker-certs/client:/docker-certs/client:ro
|
2026-08-23 16:05:18 -07:00
|
|
|
env:
|
2026-08-28 15:52:25 -07:00
|
|
|
DOCKER_HOST: tcp://localhost:2376
|
2026-08-23 16:05:18 -07:00
|
|
|
DOCKER_TLS_VERIFY: "1"
|
|
|
|
|
DOCKER_CERT_PATH: /docker-certs/client
|
2026-08-23 00:01:30 -07:00
|
|
|
steps:
|
2026-08-28 15:46:27 -07:00
|
|
|
- name: Install node (required by JS-based actions)
|
2026-08-23 16:05:18 -07:00
|
|
|
run: apk add --no-cache nodejs git
|
|
|
|
|
|
2026-08-23 00:01:30 -07:00
|
|
|
- uses: actions/checkout@v4
|
2026-08-23 16:05:18 -07:00
|
|
|
|
|
|
|
|
- name: Get short SHA
|
|
|
|
|
id: sha
|
|
|
|
|
run: |
|
|
|
|
|
SHORT_SHA=$(git rev-parse --short HEAD)
|
|
|
|
|
echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
|
|
- name: Registry login
|
|
|
|
|
run: |
|
|
|
|
|
echo "${REGISTRY_PAT}" | docker login "${REGISTRY}" \
|
|
|
|
|
--username rock --password-stdin
|
|
|
|
|
env:
|
|
|
|
|
REGISTRY_PAT: ${{ secrets.REGISTRY_PAT }}
|
|
|
|
|
|
|
|
|
|
- name: Build
|
2026-08-23 16:03:28 -07:00
|
|
|
run: |
|
|
|
|
|
docker build \
|
2026-08-23 16:05:18 -07:00
|
|
|
-t "${IMAGE}:${{ steps.sha.outputs.short_sha }}" \
|
|
|
|
|
-t "${IMAGE}:latest" \
|
|
|
|
|
.
|
|
|
|
|
|
|
|
|
|
- name: Push
|
2026-08-23 16:03:28 -07:00
|
|
|
run: |
|
2026-08-23 16:05:18 -07:00
|
|
|
docker push "${IMAGE}:${{ steps.sha.outputs.short_sha }}"
|
|
|
|
|
docker push "${IMAGE}:latest"
|