Skip to content

Update hw25-ci-cd.yml #15

Update hw25-ci-cd.yml

Update hw25-ci-cd.yml #15

Workflow file for this run

name: workflow.yml
on:
push:
branches:
- 'hw25-ci-cd/**'
jobs:
version:
name: Version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v1.1.1
with:
versionSpec: '5.x'
- name: Determine Version
uses: gittools/actions/gitversion/execute@v1.1.1
- run: |
echo "FullSemVer (env.fullSemVer) : ${{ env.fullSemVer }}"
name: Display GitVersion variables (without prefix)
- run: |
echo "FullSemVer (env.GitVersion_FullSemVer) : ${{ env.GitVersion_FullSemVer }}"
name: Display GitVersion variables (with prefix)
unit-tests:
name: Unit Tests
if: false # Remove this line to enable the job
needs:
- version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'
- name: Restore Dependencies
working-directory: './hw25-ci-cd/src'
run: dotnet restore
- name: Run Unit Tests
working-directory: './hw25-ci-cd/src'
run: dotnet test --filter FullyQualifiedName\!~IntegrationTests
integration-tests:
name: Integration Tests
if: false # Remove this line to enable the job
needs:
- version
- unit-tests
runs-on: ubuntu-latest
services:
mongo:
image: mongo:7.0.11
ports:
- 27017:27017
options: >-
--health-cmd "echo 'db.runCommand("ping").ok' | mongosh --quiet"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'
- name: Restore Dependencies
working-directory: './hw25-ci-cd/src'
run: dotnet restore
- name: Run Integration Tests
working-directory: './hw25-ci-cd/src'
run: dotnet test --filter FullyQualifiedName\!~UnitTests
build-and-push-docker-image:
name: Build and Push Docker Image
needs:
- version
# - unit-tests
# - integration-tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker Image
working-directory: './hw25-ci-cd/src/webapi'
run: docker build -t hw25-webapi:${{ env.GitVersion_FullSemVer }} .
- name: Tag Docker Image
run: docker tag hw25-webapi:${{ env.GitVersion_FullSemVer }} ${{ secrets.DOCKERHUB_USERNAME }}/hw25-webapi:${{ env.GitVersion_FullSemVer }}
- name: Push Docker Image
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/hw25-webapi:${{ env.GitVersion_FullSemVer }}