diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a189c39..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 @@ -75,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 @@ -92,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: @@ -99,23 +113,24 @@ jobs: file: Dockerfile.prod push: true tags: | - ghcr.io/${{ github.repository }}:latest - ghcr.io/${{ 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: | - ${{ env.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:latest - ${{ env.DOCKERHUB_USERNAME }}/${{ 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 }} 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