0
0
mirror of https://github.com/alex289/CleanArchitecture.git synced 2025-07-01 11:02:57 +00:00

feat: Improve ci/cd workflow

This commit is contained in:
alex289 2023-10-24 09:57:29 +02:00
parent 7e36fb7dd2
commit 2cb77f6f4b
No known key found for this signature in database
GPG Key ID: 573F77CD2D87F863
2 changed files with 42 additions and 37 deletions

View File

@ -1,29 +0,0 @@
name: Docker Image CD
on:
workflow_dispatch:
push:
branches: [ "main" ]
env:
DOCKER_IMAGE: alexdev28/clean-architecture
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
# platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.DOCKER_IMAGE }}:latest

View File

@ -1,4 +1,4 @@
name: CI
name: CI/CD
on:
workflow_dispatch:
@ -7,25 +7,59 @@ on:
pull_request:
branches: [ main ]
env:
DOCKER_IMAGE: alexdev28/clean-architecture
jobs:
build:
runs-on: ubuntu-latest
env:
solutionFile: CleanArchitecture.sln
projectName: CleanArchitecture
steps:
- uses: actions/checkout@v3
- name: Dependency Review
uses: actions/dependency-review-action@v3
with:
base-ref: ${{ github.event.pull_request.base.sha || 'main' }}
head-ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x.x
dotnet-version: |
7.x.x
6.x.x
- name: Check for vulnerabilities
run: |
VERSION=$(curl -s https://jeremylong.github.io/DependencyCheck/current.txt)
curl -Ls "https://github.com/jeremylong/DependencyCheck/releases/download/v$VERSION/dependency-check-$VERSION-release.zip" --output dependency-check.zip
unzip dependency-check.zip
./dependency-check/bin/dependency-check.sh -s "**/*.csproj" --project "${{ env.projectName }}" --failOnVCSS "7"
- name: Check for license issues
run: |
dotnet new tool-manifest
dotnet tool install --local liz.tool
dotnet liz "${{ env.solutionFile }}" --suppress-progressbar
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
docker:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
# platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.DOCKER_IMAGE }}:latest