Compare commits

..
1 Commits
Author SHA1 Message Date
rock 71fa334ba9 fix: standardize memory CI workflow to unified pattern
CI / Test (pull_request) Successful in 2m5s
CI / Build & Push Image (pull_request) Skipped
Reference: riotpiao.com action run 496/707

Unified structure:
- test job: all branches + PRs (install Node.js, checkout, cargo test/check)
- build-push job: main push only, depends on test
- Install Node.js before checkout
- Install docker.io only in build-push step
- Proper secrets (FORGEJO_REGISTRY_USER, FORGEJO_REGISTRY_TOKEN)
- Docker login + build + push + prune
2026-09-06 23:18:26 -07:00
+25 -27
View File
@@ -1,4 +1,4 @@
name: CI & Build & Push name: CI
on: on:
push: push:
@@ -10,11 +10,11 @@ on:
env: env:
REGISTRY: forgejo.riotpiao.com REGISTRY: forgejo.riotpiao.com
REGISTRY_USER: rock IMAGE: forgejo.riotpiao.com/rock/poimen-memory
jobs: jobs:
test: test:
name: Test & Lint name: Test
runs-on: rust runs-on: rust
steps: steps:
- name: Install Node.js for actions runtime - name: Install Node.js for actions runtime
@@ -29,49 +29,47 @@ jobs:
- name: Cargo check - name: Cargo check
run: cargo check -p mem-ingest 2>&1 | tail -20 || true run: cargo check -p mem-ingest 2>&1 | tail -20 || true
build-and-push: build-push:
name: Build & Push Image name: Build & Push Image
runs-on: rust
needs: test needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main' if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: rust
steps: steps:
- name: Install Node.js for actions runtime - name: Install Node.js and Docker
run: apt-get update && apt-get install -y nodejs run: |
apt-get update
apt-get install -y nodejs docker.io
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Get commit SHA - name: Get short SHA
id: sha id: sha
run: | run: |
SHORT_SHA=$(git rev-parse --short HEAD) SHORT_SHA=$(git rev-parse --short HEAD)
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
echo "Building image tag: ${{ env.REGISTRY }}/rock/poimen-memory:$SHORT_SHA"
- name: Install Docker CLI - name: Registry login
run: apt-get update && apt-get install -y docker.io
- name: Docker login
env:
REGISTRY_PAT: ${{ secrets.REGISTRY_PAT }}
run: | run: |
echo "$REGISTRY_PAT" | docker login -u ${{ env.REGISTRY_USER }} --password-stdin ${{ env.REGISTRY }} echo "${REGISTRY_TOKEN}" | docker login "${REGISTRY}" \
--username "${REGISTRY_USER}" --password-stdin
env:
REGISTRY_USER: ${{ secrets.FORGEJO_REGISTRY_USER }}
REGISTRY_TOKEN: ${{ secrets.FORGEJO_REGISTRY_TOKEN }}
- name: Build Docker image - name: Build Docker image
run: | run: |
docker build \ docker build --no-cache \
--tag ${{ env.REGISTRY }}/rock/poimen-memory:${{ steps.sha.outputs.short_sha }} \ -t "${IMAGE}:${{ steps.sha.outputs.short_sha }}" \
--tag ${{ env.REGISTRY }}/rock/poimen-memory:latest \ -t "${IMAGE}:latest" \
-f Dockerfile \ -f Dockerfile \
. .
echo "✅ Docker image built"
- name: Push Docker image - name: Push Docker image
run: | run: |
docker push ${{ env.REGISTRY }}/rock/poimen-memory:${{ steps.sha.outputs.short_sha }} docker push "${IMAGE}:${{ steps.sha.outputs.short_sha }}"
docker push ${{ env.REGISTRY }}/rock/poimen-memory:latest docker push "${IMAGE}:latest"
echo " Image pushed to registry" echo " Image pushed: ${IMAGE}:${{ steps.sha.outputs.short_sha }}"
- name: Logout from registry - name: Prune unused images
if: always() run: docker image prune -a --force 2>&1 | tail -3 || true
run: docker logout ${{ env.REGISTRY }} || true