Merge pull request #33 from stephondoestech/bug/ISSUE#30-logging #97
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: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| tags: [ 'v*' ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| permissions: | |
| contents: write | |
| packages: write | |
| env: | |
| DOCKER_IMAGE: stephondoestech/unraid-config-guardian | |
| jobs: | |
| test: | |
| name: Test & Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install -r requirements-dev.txt | |
| - name: Run tests | |
| run: pytest tests/ -v | |
| - name: Run linting | |
| run: | | |
| black --check src/ tests/ | |
| flake8 src/ tests/ --max-line-length=100 --extend-ignore=E203,W503 | |
| docker-deploy: | |
| name: Deploy to Docker Hub | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/v')) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_TOKEN }} | |
| - name: Extract metadata (develop) | |
| id: meta_develop | |
| if: github.ref == 'refs/heads/develop' | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.DOCKER_IMAGE }} | |
| tags: | | |
| type=raw,value=develop | |
| - name: Extract metadata (release tag) | |
| id: meta_release | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.DOCKER_IMAGE }} | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Build and push Docker image (develop) | |
| if: github.ref == 'refs/heads/develop' | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta_develop.outputs.tags }} | |
| labels: ${{ steps.meta_develop.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Build and push Docker image (release) | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta_release.outputs.tags }} | |
| labels: ${{ steps.meta_release.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Create GitHub Release | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| name: Release ${{ github.ref_name }} | |
| body: | | |
| ## Docker Images | |
| - `${{ env.DOCKER_IMAGE }}:${{ github.ref_name }}` | |
| - `${{ env.DOCKER_IMAGE }}:latest` | |
| ## Usage | |
| ```bash | |
| docker pull ${{ env.DOCKER_IMAGE }}:${{ github.ref_name }} | |
| ``` | |
| draft: false | |
| prerelease: false |