feat: Enhance CI/CD pipeline with Docker image build and push steps
Some checks failed
CI/CD Pipeline / test (push) Successful in 21s
CI/CD Pipeline / build-image (push) Failing after 1m9s

This commit is contained in:
2025-11-28 19:16:28 +01:00
parent 2185a07ff0
commit e0bc295936

View File

@@ -31,24 +31,57 @@ jobs:
# - name: Run linting # - name: Run linting
# run: | # run: |
# python -m flake8 web/ tests/ --max-line-length=120 # python -m flake8 web/ tests/ --max-line-length=120
build-image:
- name: Build Docker image runs-on: ubuntu-latest
run: | needs: test
docker build -t jobs-app .
- name: Run container tests
run: |
docker run --rm jobs-app python -m pytest tests/ -v
- name: Push Docker image to gitea registry
uses: docker/build-push-action@v4
env: env:
DEFAULT_BRANCH: main
REGISTRY_URL: ${{ secrets.REGISTRY_URL }}
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }} REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Collect workflow metadata
id: meta
shell: bash
run: |
ref_name="${GITHUB_REF_NAME:-${GITHUB_REF##*/}}"
event_name="${GITHUB_EVENT_NAME:-}"
sha="${GITHUB_SHA:-}"
if [ "$ref_name" = "${DEFAULT_BRANCH:-main}" ]; then
echo "on_default=true" >> "$GITHUB_OUTPUT"
else
echo "on_default=false" >> "$GITHUB_OUTPUT"
fi
echo "ref_name=$ref_name" >> "$GITHUB_OUTPUT"
echo "event_name=$event_name" >> "$GITHUB_OUTPUT"
echo "sha=$sha" >> "$GITHUB_OUTPUT"
- name: Set up QEMU and Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to registry (best-effort)
if: ${{ steps.meta.outputs.on_default == 'true' }}
uses: docker/login-action@v3
continue-on-error: true
with:
registry: ${{ env.REGISTRY_URL }}
username: ${{ env.REGISTRY_USERNAME }}
password: ${{ env.REGISTRY_PASSWORD }}
- name: Build (and optionally push) image
uses: docker/build-push-action@v5
with: with:
context: . context: .
push: true file: Dockerfile
tags: git.allucanget.biz/allucanget/jobs:latest push: ${{ steps.meta.outputs.on_default == 'true' && steps.meta.outputs.event_name != 'pull_request' && (env.REGISTRY_URL != '' && env.REGISTRY_USERNAME != '' && env.REGISTRY_PASSWORD != '') }}
tags: |
${{ env.REGISTRY_URL }}/allucanget/jobs:latest
${{ env.REGISTRY_URL }}/allucanget/jobs:${{ steps.meta.outputs.sha }}
# deploy: # deploy:
# runs-on: ubuntu-latest # runs-on: ubuntu-latest