ci: simplify workflow - remove third-party actions that don't work on Forgejo
Issues that caused stuck CI: - docker/setup-buildx-action@v3 (not reliable on Forgejo) - docker/login-action@v3 (not reliable on Forgejo) - docker/build-push-action@v5 (too complex) - GHA caching (type=gha not supported on Forgejo) Fixed with: - Plain docker commands (login, build, push) - No buildx complexity - Direct progress output - Proper cleanup on failure - Timeout-safe (no hanging processes)
This commit is contained in:
@@ -20,32 +20,11 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Cache cargo registry
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: ~/.cargo/registry
|
|
||||||
key: cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
cargo-registry-
|
|
||||||
|
|
||||||
- name: Cache cargo index
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: ~/.cargo/git
|
|
||||||
key: cargo-git-${{ hashFiles('**/Cargo.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
cargo-git-
|
|
||||||
|
|
||||||
- name: Cache build target
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: target
|
|
||||||
key: cargo-target-${{ hashFiles('**/Cargo.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
cargo-target-
|
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: cargo test --all --verbose
|
run: |
|
||||||
|
echo "Building and testing..."
|
||||||
|
cargo test --all --quiet
|
||||||
|
echo "✅ Tests passed"
|
||||||
|
|
||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
run: cargo fmt --all -- --check
|
run: cargo fmt --all -- --check
|
||||||
@@ -58,33 +37,40 @@ jobs:
|
|||||||
runs-on: docker
|
runs-on: docker
|
||||||
needs: test
|
needs: test
|
||||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||||
|
env:
|
||||||
|
DOCKER_HOST: unix:///var/run/docker.sock
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Get short SHA
|
- name: Get commit info
|
||||||
id: sha
|
id: info
|
||||||
run: |
|
run: |
|
||||||
SHORT_SHA=$(git rev-parse --short HEAD)
|
SHORT_SHA=$(git rev-parse --short HEAD)
|
||||||
|
COMMIT_MSG=$(git log -1 --pretty=%B | head -1)
|
||||||
echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
|
echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
|
||||||
|
echo "commit_msg=${COMMIT_MSG}" >> $GITHUB_OUTPUT
|
||||||
|
echo "Build: ${SHORT_SHA} - ${COMMIT_MSG}"
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Docker login
|
||||||
uses: docker/setup-buildx-action@v3
|
run: |
|
||||||
|
echo "${{ secrets.REGISTRY_PAT }}" | docker login -u rock --password-stdin ${{ env.REGISTRY }}
|
||||||
|
|
||||||
- name: Registry login
|
- name: Build image
|
||||||
uses: docker/login-action@v3
|
run: |
|
||||||
with:
|
docker build \
|
||||||
registry: ${{ env.REGISTRY }}
|
--tag ${{ env.IMAGE }}:${{ steps.info.outputs.short_sha }} \
|
||||||
username: rock
|
--tag ${{ env.IMAGE }}:latest \
|
||||||
password: ${{ secrets.REGISTRY_PAT }}
|
--progress=plain \
|
||||||
|
.
|
||||||
|
echo "✅ Image built"
|
||||||
|
|
||||||
- name: Build and push
|
- name: Push image
|
||||||
uses: docker/build-push-action@v5
|
run: |
|
||||||
with:
|
docker push ${{ env.IMAGE }}:${{ steps.info.outputs.short_sha }}
|
||||||
context: .
|
docker push ${{ env.IMAGE }}:latest
|
||||||
push: true
|
echo "✅ Image pushed"
|
||||||
tags: |
|
|
||||||
${{ env.IMAGE }}:${{ steps.sha.outputs.short_sha }}
|
- name: Cleanup
|
||||||
${{ env.IMAGE }}:latest
|
if: always()
|
||||||
cache-from: type=gha
|
run: docker logout ${{ env.REGISTRY }} || true
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
|
|||||||
Reference in New Issue
Block a user