Update build.yml

This commit is contained in:
2024-10-16 19:15:52 +02:00
committed by GitHub
parent d294e89f70
commit bb92977433

View File

@@ -1,73 +1,65 @@
name: Build and Release Angular App name: Build and Deploy
on: on:
push: push:
branches: branches:
- master - master # Change to your default branch if different
pull_request:
branches:
- master
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: self-hosted # Ensure your self-hosted runner is configured
strategy:
matrix:
node-version: [22.1]
steps: steps:
- name: Checkout repository - name: Checkout Repository
uses: actions/checkout@v4 uses: actions/checkout@v2
- name: Setup Node.js ${{ matrix.node-version }} - name: Set up .NET
uses: actions/setup-node@v4 uses: actions/setup-dotnet@v2
with: with:
node-version: ${{ matrix.node-version }} dotnet-version: '8.0' # Change to your required .NET version
- name: Install dependencies and build Angular app - name: Restore .NET Dependencies
run: dotnet restore ./services/bytefy.image/bytefy.image/bytefy.image.csproj
- name: Build .NET Project
run: dotnet build --configuration Release ./services/bytefy.image/bytefy.image/bytefy.image.csproj
- name: Publish .NET Project
run: dotnet publish ./services/bytefy.image/bytefy.image/bytefy.image.csproj --configuration Release --output ./output/dotnet
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '22.1.0' # Change to your required Node.js version
- name: Install Angular CLI
run: npm install -g @angular/cli
- name: Install Angular Dependencies
run: | run: |
cd ./tools cd ./tools
npm install --force npm install --force
npm run build
- name: Upload build artifacts - name: Build Angular App
uses: actions/upload-artifact@v3 run: |
with: cd ./tools
name: angular-app ng build --configuration production --output-path=dist
path: tools/dist/angular-app
release: deploy:
runs-on: self-hosted # Ensure your self-hosted runner is configured
needs: build needs: build
runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout Repository
uses: actions/checkout@v4 uses: actions/checkout@v2
- name: Download build artifacts - name: Copy .NET Publish Files to IIS Server
uses: actions/download-artifact@v3 run: |
with: xcopy ./output/dotnet/* "C:\inetpub\applications\bytefy.image" /s /i /y
name: angular-app xcopy ./tools/dist/tools/browser* "C:\inetpub\wwwroot\bytefy" /s /i /y
path: tools/dist/angular-app
- name: Create GitHub Release - name: Restart IIS
id: create_release run: |
uses: actions/create-release@v1 Import-Module WebAdministration
env: Restart-WebAppPool -Name "Bytefy" # Change to your App Pool Name
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} Restart-WebAppPool -Name "Bytefy.image" # Change to your App Pool Name
with:
tag_name: ${{ github.sha }}
release_name: Release ${{ github.sha }}
draft: false
prerelease: false
- name: Upload build artifact to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: tools/dist/angular-app
asset_name: angular-app.zip
asset_content_type: application/zip