--- on: push runs-on: ubuntu-latest env: test_artifacts_name: test_artifacts application_artifacts_name: application_artifacts jobs: build: env: build_artifacts_path: ${{github.workspace}}/build test_artifacts_path: ${{env.build_artifacts_path}}/tests application_artifacts_path: ${{env.build_artifacts_path}}/application NUGET_PACKAGES: ${{github.workspace}}/.nuget/packages steps: - name: Checkout repository uses: actions/checkout@v4 - name: Setup dotnet environment uses: actions/setup-dotnet@v4 with: global-json-file: global.json cache: true cache-dependency-path: | src/Application/packages.lock.json src/Infrastructure/packages.lock.json src/Persistence/packages.lock.json src/Configuration/packages.lock.json src/HttpApi/packages.lock.json tst/Application.IntegrationTests/packages.lock.json - name: Download package dependencies run: dotnet restore . - name: Build Application.IntegrationTests run: > dotnet publish ./tst/Application.IntegrationTests --output ${test_artifacts_path} --configuration Release --self-contained --use-current-runtime -p:PublishSingleFile=true -p:PublishSingleFile=true - name: Clean test artifacts directory run: > find ${test_artifacts_path} -type f -print0 | perl -0ne 'print if /.*(pdb|dll|txt|json|targets|props)/s' | xargs -r0 rm -Rf; find ${test_artifacts_path} -mindepth 1 -type d -print0 | xargs -r0 rm -Rf - name: Upload test artifacts uses: actions/upload-artifact@v3 with: name: ${{env.test_artifacts_name}} path: ${{env.test_artifacts_path}} - name: Build HttpApi project run: > dotnet publish ./src/HttpApi --output ${application_artifacts_path} --configuration Release -p:PublishSingleFile=true --self-contained --use-current-runtime -p:PublishSingleFile=true -p:PublishSingleFile=true - name: Clean application artifacts directory run: > find ${application_artifacts_path} -type f -print0 | perl -0ne 'print if /.*(\.pdb|\.dll|\.so)/s' | xargs -r0 rm -Rf; find ${application_artifacts_path} -mindepth 1 -type d -print0 | xargs -r0 rm -Rf - name: Upload application artifacts uses: actions/upload-artifact@v3 with: name: ${{env.application_artifacts_name}} path: ${{env.application_artifacts_path}} tests: needs: build env: artifacts_path: ./artifacts steps: - name: Download build artifacts uses: actions/download-artifact@v3 with: name: ${{env.test_artifacts_name}} path: ${{env.artifacts_path}} - name: Make Application.IntegrationTests executalbe run: chmod u+x ${artifacts_path}/Application.IntegrationTests - name: Run Application.IntegrationTests run: ${artifacts_path}/Application.IntegrationTests build-docker: needs: tests env: registry: gitea.cuqmbr.xyz steps: - name: Login to Docker Container Registry uses: docker/login-action@v3 with: registry: ${{env.registry}} username: ${{vars.DOCKER_USER}} password: ${{secrets.DOCKER_TOKEN}} - name: Checkout repository uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build and push uses: docker/build-push-action@v6 with: context: . file: ./Dockerfile platforms: linux/amd64 push: true # TODO: split tag names into multiple lines tags: | ${{env.registry}}/${{github.repository_owner}}/${{github.event.repository.name}}/${{github.ref_name}}:${{github.sha}} ${{env.registry}}/${{github.repository_owner}}/${{github.event.repository.name}}/${{github.ref_name}}:latest # # deploy: # needs: build-docker # steps: # - name: Checkout infrastructure repository # - name: Run ansible deployment playbook # # Use ${{github.sha}} when specifying image to deploy