Build and Push Memory Service / Build and Push Image (push) Failing after 16s
Previous run failed because: - rust:1.83-bookworm container lacks Node.js (needed for actions/checkout) - Docker not available in the rust container - actions/checkout@v4 is a third-party action that needs Node Solution: - Use docker:27-dind container (has docker + git preinstalled) - Replace actions/checkout with direct git clone + checkout - All steps run directly in the docker container This matches Forgejo's native environment better than trying to run GitHub Actions inside a Rust container.
59 lines
1.7 KiB
YAML
59 lines
1.7 KiB
YAML
name: Build and Push Memory Service
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build-and-push:
|
|
name: Build and Push Image
|
|
runs-on: rust
|
|
container:
|
|
image: docker:27-dind
|
|
options: --privileged
|
|
steps:
|
|
- name: Checkout code
|
|
run: |
|
|
apk add --no-cache git
|
|
git clone https://git.riotpiao.com:2222/rock/poimen-memory.git /workspace
|
|
cd /workspace
|
|
git checkout ${{ github.sha }}
|
|
|
|
- name: Get commit info
|
|
id: info
|
|
run: |
|
|
cd /workspace
|
|
SHORT_SHA=$(git rev-parse --short HEAD)
|
|
COMMIT_MSG=$(git log -1 --pretty=%B | head -1)
|
|
echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
|
|
echo "commit_msg=${COMMIT_MSG}" >> $GITHUB_OUTPUT
|
|
echo "Building: ${SHORT_SHA} - ${COMMIT_MSG}"
|
|
|
|
- name: Docker login
|
|
run: |
|
|
echo "${{ secrets.REGISTRY_PAT }}" | \
|
|
docker login -u rock --password-stdin forgejo.riotpiao.com
|
|
|
|
- name: Build image
|
|
run: |
|
|
cd /workspace
|
|
docker build \
|
|
--tag forgejo.riotpiao.com/rock/poimen-memory:${{ steps.info.outputs.short_sha }} \
|
|
--tag forgejo.riotpiao.com/rock/poimen-memory:latest \
|
|
.
|
|
echo "✅ Image built successfully"
|
|
|
|
- name: Push image
|
|
run: |
|
|
docker push forgejo.riotpiao.com/rock/poimen-memory:${{ steps.info.outputs.short_sha }}
|
|
docker push forgejo.riotpiao.com/rock/poimen-memory:latest
|
|
echo "✅ Image pushed successfully"
|
|
echo "Image: forgejo.riotpiao.com/rock/poimen-memory:latest"
|
|
|
|
- name: Cleanup
|
|
if: always()
|
|
run: |
|
|
docker logout forgejo.riotpiao.com || true
|
|
echo "✅ Cleanup complete"
|