From 9f9fabc749fb1f21a50136f558d577e6d00179b5 Mon Sep 17 00:00:00 2001 From: yurvon-screamo Date: Tue, 20 Aug 2024 23:18:34 +0300 Subject: [PATCH] add build release --- .github/dotnet/action.yaml | 10 +++++ .github/workflows/ci.yaml | 45 ++++++++++++++++++++++ .github/workflows/docker-image-release.yml | 13 +++---- .github/workflows/docker-image.yml | 16 -------- 4 files changed, 61 insertions(+), 23 deletions(-) create mode 100644 .github/dotnet/action.yaml create mode 100644 .github/workflows/ci.yaml delete mode 100644 .github/workflows/docker-image.yml diff --git a/.github/dotnet/action.yaml b/.github/dotnet/action.yaml new file mode 100644 index 0000000..6ef5b96 --- /dev/null +++ b/.github/dotnet/action.yaml @@ -0,0 +1,10 @@ +name: dotnet setup +description: "base dotnet setup for project" +runs: + using: composite + steps: + - name: setup + id: setup-dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: "8.0.300" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..264e939 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,45 @@ +name: ci + +on: + push: + branches: + - main + pull_request: + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - name: setup dotnet + uses: ./.github/dotnet + - uses: actions/checkout@v2 + - name: Run dotnet build + run: dotnet build --configuration Debug + + fmt: + runs-on: ubuntu-latest + steps: + - name: setup dotnet + uses: ./.github/dotnet + - uses: actions/checkout@v2 + - name: dotnet format check + run: dotnet format --verify-no-changes *.sln + env: + PATH: ${{ github.env.PATH }}:/home/runner/.dotnet/tools + + unit-test: + runs-on: ubuntu-latest + steps: + - name: setup dotnet + uses: ./.github/dotnet + - uses: actions/checkout@v2 + - name: unit test + run: dotnet test *sln + + image-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build the Docker image + run: docker build . --file Dockerfile --tag yurvon-screamo/redfish.mockup.server:$(date +%s) diff --git a/.github/workflows/docker-image-release.yml b/.github/workflows/docker-image-release.yml index b17f99b..004ceda 100644 --- a/.github/workflows/docker-image-release.yml +++ b/.github/workflows/docker-image-release.yml @@ -1,18 +1,17 @@ -name: Build and Push Docker Image +name: Publish release on: release: - push: - branches: [ "main" ] + types: [published] jobs: build: runs-on: ubuntu-latest - steps: + - name: Checkout code uses: actions/checkout@v3 - + - name: Log in to GitHub Container Registry uses: docker/login-action@v2 with: @@ -21,7 +20,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build Docker image - run: docker build . -t ghcr.io/yurvon-screamo/redfish-mockup-server:latest + run: docker build . -t ghcr.io/yurvon-screamo/redfish-mockup-server:${{ github.event.release.tag_name }} - name: Push Docker image - run: env + run: docker push ghcr.io/yurvon-screamo/redfish-mockup-server:${{ github.event.release.tag_name }} diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml deleted file mode 100644 index 02fda0d..0000000 --- a/.github/workflows/docker-image.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Build Docker Image - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -jobs: - - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag yurvon-screamo/redfish.mockup.server:$(date +%s)