From c4ce7734b5124c8721e9ca4b88ac1d714588ff2c Mon Sep 17 00:00:00 2001 From: Winz79 Date: Sat, 9 Aug 2025 19:07:50 +0200 Subject: [PATCH 1/3] Fix image tag casing issues --- .github/workflows/ci.yml | 21 ++++++++++++++++++++- .gitignore | 2 +- gitignore | 5 ----- mykey.pub | 1 - 4 files changed, 21 insertions(+), 8 deletions(-) delete mode 100644 gitignore delete mode 100644 mykey.pub diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a189c39..dee084b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,26 @@ jobs: - name: Run unit tests with coverage run: | python -m pytest --cov=app --cov-report=xml:coverage.xml --cov-report=term-missing tests/unit -q - - name: Upload coverage to Codecov + - name: Build and push image to GHCR + uses: docker/build-push-action@v4 + with: + context: . + file: Dockerfile.prod + push: true + tags: | + ghcr.io/${{ toLower(github.repository_owner) }}/${{ toLower(github.event.repository.name) }}:latest + ghcr.io/${{ toLower(github.repository_owner) }}/${{ toLower(github.event.repository.name) }}:${{ github.sha }} + + - name: Optionally push to Docker Hub + if: ${{ env.DOCKERHUB_USERNAME && env.DOCKERHUB_TOKEN }} + uses: docker/build-push-action@v4 + with: + context: . + file: Dockerfile.prod + push: true + tags: | + ${{ toLower(env.DOCKERHUB_USERNAME) }}/${{ toLower(github.event.repository.name) }}:latest + ${{ toLower(env.DOCKERHUB_USERNAME) }}/${{ toLower(github.event.repository.name) }}:${{ github.sha }} uses: codecov/codecov-action@v4 with: files: coverage.xml diff --git a/.gitignore b/.gitignore index bf3c301..072b217 100644 --- a/.gitignore +++ b/.gitignore @@ -17,5 +17,5 @@ dist/ *.egg .DS_Store .ipynb_checkpoints -/.vscode/ /.idea/ + diff --git a/gitignore b/gitignore deleted file mode 100644 index cb36686..0000000 --- a/gitignore +++ /dev/null @@ -1,5 +0,0 @@ -__pycache__/ -.env -.env.* -venv/ -*.pyc diff --git a/mykey.pub b/mykey.pub deleted file mode 100644 index b7d50a5..0000000 --- a/mykey.pub +++ /dev/null @@ -1 +0,0 @@ -ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMFmodBhzgLm7LUQoBGhMo9DPtw1Mys0cC74uMTbu+yY seb@witzops From 430f1590662b0770076e2fe80e724180fb6cd63a Mon Sep 17 00:00:00 2001 From: Winz79 Date: Sat, 9 Aug 2025 19:11:13 +0200 Subject: [PATCH 2/3] Fix GHCR tag casing and remove malformed expressions --- .github/workflows/ci.yml | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dee084b..1a048d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,30 +61,10 @@ jobs: - name: Run unit tests with coverage run: | python -m pytest --cov=app --cov-report=xml:coverage.xml --cov-report=term-missing tests/unit -q - - name: Build and push image to GHCR - uses: docker/build-push-action@v4 - with: - context: . - file: Dockerfile.prod - push: true - tags: | - ghcr.io/${{ toLower(github.repository_owner) }}/${{ toLower(github.event.repository.name) }}:latest - ghcr.io/${{ toLower(github.repository_owner) }}/${{ toLower(github.event.repository.name) }}:${{ github.sha }} - - - name: Optionally push to Docker Hub - if: ${{ env.DOCKERHUB_USERNAME && env.DOCKERHUB_TOKEN }} - uses: docker/build-push-action@v4 - with: - context: . - file: Dockerfile.prod - push: true - tags: | - ${{ toLower(env.DOCKERHUB_USERNAME) }}/${{ toLower(github.event.repository.name) }}:latest - ${{ toLower(env.DOCKERHUB_USERNAME) }}/${{ toLower(github.event.repository.name) }}:${{ github.sha }} + - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: files: coverage.xml - build-and-publish: runs-on: ubuntu-latest needs: test @@ -118,8 +98,8 @@ jobs: file: Dockerfile.prod push: true tags: | - ghcr.io/${{ github.repository }}:latest - ghcr.io/${{ github.repository }}:${{ github.sha }} + ghcr.io/${ toLower(github.repository) }}:latest + ghcr.io/${ toLower(github.repository) }}:${ github.sha }} - name: Optionally push to Docker Hub if: ${{ env.DOCKERHUB_USERNAME && env.DOCKERHUB_TOKEN }} uses: docker/build-push-action@v4 @@ -128,8 +108,8 @@ jobs: file: Dockerfile.prod push: true tags: | - ${{ env.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:latest - ${{ env.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:${{ github.sha }} + ${{ toLower(env.DOCKERHUB_USERNAME) }}/${ toLower(github.event.repository.name) }}:latest + ${{ toLower(env.DOCKERHUB_USERNAME) }}/${ toLower(github.event.repository.name) }}:${ github.sha }} - name: Create release (optional) if: github.event_name == 'workflow_dispatch' uses: ncipollo/release-action@v1 From 63ade3be818848b0e8bc0917e639318e7113c7ab Mon Sep 17 00:00:00 2001 From: Winz79 Date: Sat, 9 Aug 2025 19:17:46 +0200 Subject: [PATCH 3/3] Compute lowercase image names in job and use env vars for docker tags --- .github/workflows/ci.yml | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a048d4..3084775 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: uses: actions/cache@v4 with: path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + key: ${{ runner.os }}-pip-${ hashFiles('**/requirements.txt') }} - name: Install flake8 run: | python -m pip install --upgrade pip @@ -53,7 +53,7 @@ jobs: uses: actions/cache@v4 with: path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + key: ${{ runner.os }}-pip-${ hashFiles('**/requirements.txt') }} - name: Install dependencies run: | python -m pip install --upgrade pip setuptools wheel @@ -65,6 +65,7 @@ jobs: uses: codecov/codecov-action@v4 with: files: coverage.xml + build-and-publish: runs-on: ubuntu-latest needs: test @@ -74,16 +75,29 @@ jobs: DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} steps: - uses: actions/checkout@v4 + - name: Set up QEMU uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 + + - name: Prepare lowercase image names + run: | + echo "IMAGE_NAME=$(echo \"${GITHUB_REPOSITORY}\" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + if [ -n "${DOCKERHUB_USERNAME:-}" ]; then + REPO_NAME="${GITHUB_REPOSITORY##*/}" + echo "DOCKERHUB_IMAGE=$(echo \"${DOCKERHUB_USERNAME}/${REPO_NAME}\" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + fi + shell: bash + - name: Log into GitHub Container Registry uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Optionally log into Docker Hub if: ${{ env.DOCKERHUB_USERNAME && env.DOCKERHUB_TOKEN }} uses: docker/login-action@v2 @@ -91,6 +105,7 @@ jobs: registry: docker.io username: ${{ env.DOCKERHUB_USERNAME }} password: ${{ env.DOCKERHUB_TOKEN }} + - name: Build and push image to GHCR uses: docker/build-push-action@v4 with: @@ -98,23 +113,24 @@ jobs: file: Dockerfile.prod push: true tags: | - ghcr.io/${ toLower(github.repository) }}:latest - ghcr.io/${ toLower(github.repository) }}:${ github.sha }} + ghcr.io/${ env.IMAGE_NAME }}:latest + ghcr.io/${ env.IMAGE_NAME }}:${ github.sha }} + - name: Optionally push to Docker Hub - if: ${{ env.DOCKERHUB_USERNAME && env.DOCKERHUB_TOKEN }} + if: ${{ env.DOCKERHUB_USERNAME && env.DOCKERHUB_TOKEN && env.DOCKERHUB_IMAGE }} uses: docker/build-push-action@v4 with: context: . file: Dockerfile.prod push: true tags: | - ${{ toLower(env.DOCKERHUB_USERNAME) }}/${ toLower(github.event.repository.name) }}:latest - ${{ toLower(env.DOCKERHUB_USERNAME) }}/${ toLower(github.event.repository.name) }}:${ github.sha }} + ${{ env.DOCKERHUB_IMAGE }}:latest + ${{ env.DOCKERHUB_IMAGE }}:${ github.sha }} - name: Create release (optional) if: github.event_name == 'workflow_dispatch' uses: ncipollo/release-action@v1 with: - tag: v${{ github.run_number }} + tag: v${ github.run_number }} name: "Automated release ${{ github.run_number }}" body: | Automated release from CI build ${{ github.run_id }}