Last active
May 26, 2023 12:21
-
-
Save kolosovpetro/3868baab552d9667845f07afc800720c to your computer and use it in GitHub Desktop.
Pipelines templates
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
trigger: | |
batch: true | |
branches: | |
include: | |
- master | |
paths: | |
include: | |
- '*' | |
#trigger: none | |
variables: | |
- name: acrName | |
value: 'carsislandacr' | |
- name: acrUrl | |
value: 'carsislandacr.azurecr.io' | |
- name: acrRepository | |
value: 'cars-island-web-app' | |
- name: image | |
value: 'cars-web-app' | |
- name: dockerFilePath | |
value: './src/cars-island-web-app' | |
stages: | |
- stage: "docker_webapp_build_push" | |
displayName: "Docker Web App build push" | |
jobs: | |
- job: Build_Push_Docker_Image | |
displayName: "Build push docker image" | |
pool: | |
vmImage: "ubuntu-latest" | |
steps: | |
- checkout: self | |
fetchDepth: 0 | |
- task: gitversion/setup@0 | |
displayName: 'GitVersion Setup' | |
inputs: | |
versionSpec: '5.9.x' | |
- task: gitversion/execute@0 | |
displayName: 'GitVersion Execute' | |
inputs: | |
updateAssemblyInfo: true | |
- bash: echo $Action$BuildVersion | |
displayName: 'Set Build Version' | |
env: | |
Action: '##vso[build.updatebuildnumber]' | |
BuildVersion: $(GitVersion.SemVer) | |
- bash: | | |
IMAGE_FULL_NAME="$ACR_URL/$ACR_REPOSITORY:$IMAGE-$VERSION" | |
echo "Image full name: $IMAGE_FULL_NAME" | |
docker build -t "$IMAGE_FULL_NAME" "$DOCKERFILE_PATH" | |
env: | |
ACR_URL: $(acrUrl) | |
ACR_REPOSITORY: $(acrRepository) | |
IMAGE: $(image) | |
VERSION: $(GitVersion.SemVer) | |
DOCKERFILE_PATH: $(dockerFilePath) | |
displayName: 'Build Docker Image' | |
- bash: docker images | |
displayName: 'List Docker Images' | |
- task: AzureCLI@2 | |
displayName: 'Push image to ACR' | |
inputs: | |
azureSubscription: 'CarsIslandACR_SP_Service_connection' | |
scriptType: 'bash' | |
scriptLocation: 'inlineScript' | |
inlineScript: | | |
az acr login --name "$(acrName)" | |
docker image push -a "$(acrUrl)/$(acrRepository)" |
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: Build WebApp | |
on: | |
push: | |
branches: | |
- master | |
- main | |
- develop | |
pull_request: | |
branches: | |
- master | |
- main | |
- develop | |
workflow_dispatch: | |
schedule: | |
- cron: '0 0 * * 0' | |
jobs: | |
build-webapp: | |
name: Build Web App | |
runs-on: ${{ matrix.environment }} | |
strategy: | |
matrix: | |
environment: | |
- ubuntu-latest | |
- windows-latest | |
env: | |
DOTNET_NOLOGO: 1 | |
DOTNET_CLI_TELEMETRY_OPTOUT: 1 | |
NUGET_PACKAGES: ${{ github.workspace }}/.github/nuget-packages | |
ProjectPath: './src/cars-island-web-app/CarsIsland.WebApp/CarsIsland.WebApp.csproj' | |
Configuration: 'Release' | |
Solution: 'CarsIsland.sln' | |
ArtifactName: 'cars-island-web-app' | |
ArtifactPath: 'publish' | |
steps: | |
- name: Fetch Sources | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: '5.x' | |
- name: Determine Version | |
uses: gittools/actions/gitversion/[email protected] | |
- name: Setup .NET 6.0 SDK | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 6.0.x | |
- name: NuGet Cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.NUGET_PACKAGES }} | |
key: ${{ runner.os }}.nuget.${{ hashFiles('**/*.csproj') }} | |
- name: Nuget Restore | |
run: dotnet restore | |
- name: Build Solution | |
run: | | |
dotnet build ${{ env.Solution }} --configuration ${{ env.Configuration }} /p:ContinuousIntegrationBuild=true --no-restore | |
- name: Run .NET Publish | |
run: | | |
dotnet publish ${{ env.ProjectPath }} --configuration ${{ env.Configuration }} --output ${{ env.ArtifactPath }} | |
- name: Drop Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: '${{ env.ArtifactName }}-${{ matrix.environment }}' | |
path: ${{ env.ArtifactPath }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment