mirror of
https://github.com/alex289/CleanArchitecture.git
synced 2025-06-29 18:21:08 +00:00
90 lines
2.2 KiB
YAML
90 lines
2.2 KiB
YAML
name: CI/CD
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches: [ main ]
|
|
tags:
|
|
- 'v*'
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
env:
|
|
DOCKER_IMAGE: alexdev28/clean-architecture
|
|
|
|
jobs:
|
|
ci:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
solutionFile: CleanArchitecture.sln
|
|
projectName: CleanArchitecture
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install .NET Core
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: |
|
|
9.x.x
|
|
|
|
- name: Restore dependencies
|
|
run: dotnet restore
|
|
|
|
- name: Build
|
|
run: dotnet build --no-restore
|
|
|
|
- name: Test
|
|
run: dotnet test --no-build --verbosity normal
|
|
|
|
cd:
|
|
runs-on: ubuntu-latest
|
|
needs: ci
|
|
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- 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: Login to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: |
|
|
${{ env.DOCKER_IMAGE }}
|
|
ghcr.io/${{ github.repository }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
- name: Docker Hub Description
|
|
uses: peter-evans/dockerhub-description@v4
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
repository: ${{ env.DOCKER_IMAGE }}
|
|
readme-filepath: ./Readme.md |