Skip to content

Merge pull request #6 from InvisibleSafe/test/post-service-integratio… #31

Merge pull request #6 from InvisibleSafe/test/post-service-integratio…

Merge pull request #6 from InvisibleSafe/test/post-service-integratio… #31

Workflow file for this run

name: Post Service CI/CD Pipeline
on:
push:
paths:
- backend/src/**
- .github/workflows/post.yml
branches:
- master
- develop
tags:
- 'v*'
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'
- name: Restore dependencies
run: dotnet restore ./FitnessApp.sln
- name: Build project
run: dotnet build --configuration Release ./FitnessApp.sln --no-restore
- name: Run tests
run: |
dotnet test ./backend/tests/PostService/PostService.Domain.Tests/PostService.Domain.Tests.csproj --configuration Release --no-build --verbosity normal
dotnet test ./backend/tests/PostService/PostService.Application.Tests/PostService.Application.Tests.csproj --configuration Release --no-build --verbosity normal
docker:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin
- name: Build Docker image
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
IMAGE_VERSION=${GITHUB_REF#refs/tags/}
docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/post-service:${IMAGE_VERSION} -f ./backend/src/PostService/Dockerfile ./backend
else
echo "Skipping Docker image build because this is not a tag push."
fi
- name: Push Docker image to Docker Hub
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
IMAGE_VERSION=${GITHUB_REF#refs/tags/}
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/post-service:${IMAGE_VERSION}
else
echo "Skipping Docker image push because this is not a tag push."
fi