Skip to content

Commit

Permalink
Enabling-new-CI-CD-for-Identity-API (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
jurabek committed Oct 3, 2023
1 parent f499b78 commit a383914
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 67 deletions.
82 changes: 17 additions & 65 deletions .github/workflows/identity-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,75 +5,27 @@ on:
branches:
- develop
paths:
- 'src/backend/services/order.api/**'
- '.github/workflows/identity-api.yml'
- "src/backend/services/identity-api/**"
- ".github/workflows/identity-api.yml"
pull_request:
branches:
- develop
paths:
- 'src/backend/services/identity.api/**'
- '.github/workflows/identity-api.yml'
- "src/backend/services/identity-api/**"
- ".github/workflows/identity-api.yml"

jobs:
build-and-test:
name: build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.100
build-release:
uses: ./.github/workflows/build-release.yml
with:
service-name: identity-api
secrets: inherit

- name: Setup cache
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/Identity.API/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Build
run: |
chmod -R +x scripts/
scripts/build.sh identity_api
working-directory: ./src/backend/

- name: Test & QA
run: |
chmod -R +x scripts/
scripts/qa.sh identity_api
working-directory: ./src/backend/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload menu-api artifact
uses: actions/upload-artifact@v3
with:
name: identity_api
path: ./src/backend/services/identity.api/identity-api-release

docker-push:
needs: build-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Download basket-api artifact
uses: actions/download-artifact@v1
with:
name: identity_api
- name: Copy artifact to working directory
shell: bash
run: |
cp -r identity_api/ ./src/backend/services/identity.api/identity-api-release
- name: Publish docker image
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: jurabek/menu
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
dockerfile: release.Dockerfile
workdir: ./src/backend/services/identity.api
deploy:
if: github.ref == 'refs/heads/develop'
needs:
- build-release
uses: ./.github/workflows/deploy.yml
with:
service-name: identity-api
version: ${{ needs.build-release.outputs.new-version }}
4 changes: 4 additions & 0 deletions src/backend/services/identity-api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
FROM --platform=linux/arm64 mcr.microsoft.com/dotnet/core/sdk:3.1.426-buster-arm64v8 AS build
WORKDIR /src
COPY Identity.API/ ./api
COPY Identity.API.UnitTests ./tests

RUN dotnet restore api/Identity.API.csproj
RUN dotnet restore tests/Identity.API.UnitTests.csproj

COPY . .

WORKDIR /src

RUN dotnet test -t Identity.API.UnitTests/Identity.API.UnitTests.csproj
RUN dotnet build api/Identity.API.csproj -c Release -o /app

FROM build AS publish
Expand Down
10 changes: 8 additions & 2 deletions src/backend/services/identity-api/Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine

FROM --platform=linux/arm64 mcr.microsoft.com/dotnet/core/sdk:3.1.426-buster-arm64v8 AS build
WORKDIR /src
COPY Identity.API.UnitTests ./tests

RUN dotnet restore tests/Identity.API.UnitTests.csproj

COPY . .

ENTRYPOINT [ "/bin/sh" ]
WORKDIR /src
RUN dotnet test -t Identity.API.UnitTests/Identity.API.UnitTests.csproj

0 comments on commit a383914

Please sign in to comment.