Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
030114eac9 |
+46
-34
@@ -1,26 +1,24 @@
|
||||
name: CI
|
||||
name: CI & Build & Push
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
REGISTRY: forgejo.riotpiao.com
|
||||
IMAGE: forgejo.riotpiao.com/rock/poimen-memory
|
||||
DOCKER_HOST: tcp://localhost:2375
|
||||
REGISTRY_USER: rock
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
name: CI
|
||||
test:
|
||||
name: Test & Lint
|
||||
runs-on: rust
|
||||
steps:
|
||||
- name: Install Node.js and Docker
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y nodejs docker.io
|
||||
- name: Install Node.js for actions runtime
|
||||
run: apt-get update && apt-get install -y nodejs
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
@@ -31,35 +29,49 @@ jobs:
|
||||
- name: Cargo check
|
||||
run: cargo check -p mem-ingest 2>&1 | tail -20 || true
|
||||
|
||||
- name: Get short SHA
|
||||
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
||||
id: sha
|
||||
run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
build-and-push:
|
||||
name: Build & Push Image
|
||||
runs-on: rust
|
||||
needs: test
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||
steps:
|
||||
- name: Install Node.js for actions runtime
|
||||
run: apt-get update && apt-get install -y nodejs
|
||||
|
||||
- name: Registry login
|
||||
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get commit SHA
|
||||
id: sha
|
||||
run: |
|
||||
echo "${REGISTRY_TOKEN}" | docker login "${REGISTRY}" \
|
||||
--username "${REGISTRY_USER}" --password-stdin
|
||||
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: Install Docker CLI
|
||||
run: apt-get update && apt-get install -y docker.io
|
||||
|
||||
- name: Docker login
|
||||
env:
|
||||
REGISTRY_USER: ${{ secrets.FORGEJO_REGISTRY_USER }}
|
||||
REGISTRY_TOKEN: ${{ secrets.FORGEJO_REGISTRY_TOKEN }}
|
||||
REGISTRY_PAT: ${{ secrets.REGISTRY_PAT }}
|
||||
run: |
|
||||
echo "$REGISTRY_PAT" | docker login -u ${{ env.REGISTRY_USER }} --password-stdin ${{ env.REGISTRY }}
|
||||
|
||||
- name: Build Docker image
|
||||
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
||||
run: |
|
||||
docker build --no-cache \
|
||||
-t "${IMAGE}:${{ steps.sha.outputs.short_sha }}" \
|
||||
-t "${IMAGE}:latest" \
|
||||
-f Dockerfile .
|
||||
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
|
||||
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
||||
run: |
|
||||
docker push "${IMAGE}:${{ steps.sha.outputs.short_sha }}"
|
||||
docker push "${IMAGE}:latest"
|
||||
echo "✓ Pushed: ${IMAGE}:${{ steps.sha.outputs.short_sha }}"
|
||||
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: Prune unused images
|
||||
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
||||
run: docker image prune -a --force 2>&1 | tail -3 || true
|
||||
- name: Logout from registry
|
||||
if: always()
|
||||
run: docker logout ${{ env.REGISTRY }} || true
|
||||
|
||||
Reference in New Issue
Block a user