This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build, Test, Push Docker image | |
| on: | |
| push: | |
| branches: [main] # Triggers when you push to the main branch | |
| workflow_dispatch: # Allows to be run manually from the GitHub UI | |
| jobs: | |
| docker: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read # Needed to read the repo content | |
| packages: write # Needed to publish to GHCR (GitHub Container Registry) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install Mosquitto | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y mosquitto | |
| sudo systemctl stop mosquitto | |
| sudo systemctl disable mosquitto | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10" | |
| cache: "pip" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip setuptools wheel | |
| pip install -r src/requirements.txt | |
| - name: Test with pytest | |
| run: | | |
| pip install -r tests/requirements.txt | |
| pytest -v --cov=main --cov=lib --cov-report=html | |
| - name: Upload pytest test results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pytest-results | |
| path: htmlcov/ | |
| # Use always() to always run this step to publish test results when there are test failures | |
| if: ${{ always() }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract repository name | |
| id: meta | |
| run: echo "REPO=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV | |
| - name: Extract repository lowercase name | |
| id: repo_lowercase | |
| run: echo "REPO_LOWERCASE=${GITHUB_REPOSITORY@L}" >> $GITHUB_ENV # Print the repo as lowercase in env variables, needed for GHCR | |
| - name: Build and Push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./src | |
| push: true | |
| tags: ghcr.io/${{ env.REPO_LOWERCASE }}/frameweaver:latest |