test #3
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: CI | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| - feat/hw-* | |
| paths: | |
| - 'Homeworks/06 Настройка CI/**' | |
| env: | |
| IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/promocode-factory-api | |
| jobs: | |
| ci: | |
| name: Test, Build & Push | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| checks: write | |
| packages: write | |
| defaults: | |
| run: | |
| working-directory: Homeworks/06 Настройка CI/src | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build SDK image | |
| run: docker build --target build -t sdk-build -f Dockerfile . | |
| - name: Run tests | |
| run: | | |
| mkdir -p "${{ github.workspace }}/test-results" | |
| docker run --rm \ | |
| -v "${{ github.workspace }}/test-results:/test-results" \ | |
| sdk-build \ | |
| dotnet test ./PromoCodeFactory.UnitTests/PromoCodeFactory.UnitTests.csproj \ | |
| -c Release --no-build \ | |
| --logger "trx;LogFileName=test-results.trx" \ | |
| --results-directory /test-results | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results | |
| path: test-results/ | |
| - name: Publish test report | |
| uses: dorny/test-reporter@v1 | |
| if: always() | |
| with: | |
| name: Unit Tests | |
| path: test-results/**/*.trx | |
| reporter: dotnet-trx | |
| - name: Set up Docker Buildx | |
| if: github.event_name == 'push' | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| if: github.event_name == 'push' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Docker metadata | |
| if: github.event_name == 'push' | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=sha | |
| type=ref,event=branch | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Build & push image | |
| if: github.event_name == 'push' | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: Homeworks/06 Настройка CI/src | |
| target: final | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |