Initial commit #1
This file contains hidden or 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: Template - build and test | |
| on: | |
| push: | |
| branches: [ main, development ] | |
| pull_request: | |
| branches: [ development ] | |
| # Add manual workflow dispatch trigger | |
| workflow_dispatch: | |
| inputs: | |
| reason: | |
| description: 'Reason for running the workflow' | |
| required: false | |
| default: 'Manual execution' | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| with: | |
| submodules: recursive # Checkout submodules recursively | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v3.2.0 | |
| with: | |
| dotnet-version: 9.0 | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build --no-restore --configuration Release | |
| - name: Test | |
| run: dotnet test | |
| Deploy: | |
| needs: build | |
| if: github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v2 | |
| with: | |
| submodules: recursive # Checkout submodules recursively | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v3.2.0 | |
| with: | |
| dotnet-version: 9.0 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v1 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and Push API Container | |
| run: | | |
| dotnet publish ./Template.Api/Template.Api.csproj -c Release --os linux --arch arm64 /t:PublishContainer | |
| - name: Build and Push Web Container | |
| run: | | |
| dotnet publish ./Template.Web/Template.Web.csproj -c Release --os linux --arch arm64 /t:PublishContainer |