Single Community Apps template + drop unknown/unknown image manifest #178
Workflow file for this run
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 and Publish Docker Image | |
| on: | |
| push: | |
| branches: [dev, v3.0, main] | |
| tags: ['v*'] | |
| pull_request: | |
| branches: [dev, v3.0, main] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: pip install -r requirements-dev.txt | |
| - name: Syntax check uncovered modules | |
| run: | | |
| python -c " | |
| import py_compile, glob, sys | |
| errors = [] | |
| for f in glob.glob('web/routers/*.py') + glob.glob('web/services/*.py'): | |
| try: | |
| py_compile.compile(f, doraise=True) | |
| except py_compile.PyCompileError as e: | |
| errors.append(str(e)) | |
| if errors: | |
| print('\n'.join(errors)) | |
| sys.exit(1) | |
| " | |
| - name: Run tests | |
| run: python -m pytest tests/ -v --tb=short | |
| build-and-push: | |
| needs: test | |
| if: github.event_name == 'push' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| if: vars.DOCKERHUB_ENABLED == 'true' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ${{ vars.DOCKERHUB_ENABLED == 'true' && format('{0}/plexcache-d', secrets.DOCKERHUB_USERNAME) || '' }} | |
| ghcr.io/${{ github.repository_owner }}/plexcache-d | |
| tags: | | |
| # dev tag for dev branch | |
| type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }} | |
| # latest tag for v3.0 and main branches | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/v3.0' || github.ref == 'refs/heads/main' }} | |
| # semver tags for version tags (v3.0.1 -> latest, v3.0.1, v3.0, v3) | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-') }} | |
| - name: Compute IMAGE_TAG build arg | |
| id: image_tag | |
| run: | | |
| if [[ "$GITHUB_REF" == refs/heads/dev ]]; then | |
| echo "value=dev" >> "$GITHUB_OUTPUT" | |
| elif [[ "$GITHUB_REF" == refs/tags/v* ]]; then | |
| echo "value=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "value=latest" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: docker/Dockerfile | |
| push: true | |
| provenance: false | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| build-args: | | |
| GIT_COMMIT=${{ github.sha }} | |
| IMAGE_TAG=${{ steps.image_tag.outputs.value }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |