ci: Update dotnet.yml #27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: .NET | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: | |
name: actions_back_front_orange_finance | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Semantic Release | |
id: semantic_release | |
uses: cycjimmy/semantic-release-action@v4 | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
- name: Extract and format release version | |
run: | | |
echo "Extracting version from Semantic Release output" | |
RELEASE_VERSION="${{ steps.semantic_release.outputs.newReleaseVersion }}" | |
CLEANED_VERSION="${RELEASE_VERSION#v}" | |
echo "NEXT_VERSION=$CLEANED_VERSION" >> $GITHUB_ENV | |
echo "Formatted version (NEXT_VERSION): $CLEANED_VERSION" | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 8.x | |
- name: Restore dependencies | |
run: dotnet restore Back-Orange-Finance/Orange-Finance/OrangeFinance.csproj | |
- name: Build application | |
run: dotnet build Back-Orange-Finance/Orange-Finance/OrangeFinance.csproj --no-restore --configuration Release | |
- name: Publish application | |
run: dotnet publish Back-Orange-Finance/Orange-Finance/OrangeFinance.csproj --no-build --configuration Release -o out | |
- name: Log in to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: Back-Orange-Finance | |
file: Back-Orange-Finance/Orange-Finance/Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKER_USERNAME }}/orange-finance-backend:${{ env.NEXT_VERSION }} | |
- name: Scan Docker image for vulnerabilities | |
uses: aquasecurity/[email protected] | |
with: | |
image-ref: ${{ secrets.DOCKER_USERNAME }}/orange-finance-backend:${{ env.NEXT_VERSION }} |