Skip to content

Commit

Permalink
GitHub Actions and Azure Pipelines (#29)
Browse files Browse the repository at this point in the history
* remove deploy from develop

* Labeler Action (#24)

* Create label.yml

* Create labeler.yml

* Dotnet Build  (#25)

* Create dotnet-webapp.yml

* Create dotnet-webapi.yml

* Set up CI with Azure Pipelines (#26)

[skip ci]

* Remove unused files (#27)

* Remove unused files

* include releases in docker build

* Add CodeQL
  • Loading branch information
khaneliman authored Nov 7, 2021
1 parent 37435a6 commit d5fa200
Show file tree
Hide file tree
Showing 9 changed files with 207 additions and 369 deletions.
17 changes: 17 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
WebApp:
- WebApp/**/*

WebApi:
- WebApi/**/*

test:
- WebApp/ClientApp/src/**/*.spec.js

Angular:
- WebApp/ClientApp/**/*

repo:
- '*'

GitHub-Action:
- .github/workflows/*
70 changes: 70 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master, develop ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '30 2 * * 1'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'csharp', 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
29 changes: 29 additions & 0 deletions .github/workflows/dotnet-webapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: .NET WebApi Build

on:
push:
branches: [ develop, master ]
paths:
- 'WebApi/**/*'
pull_request:
branches: [ develop, master ]
paths:
- 'WebApi/**/*'

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore WebApi/
- name: Build
run: dotnet build WebApi/ --no-restore
- name: Test
run: dotnet test WebApi/ --no-build --verbosity normal
29 changes: 29 additions & 0 deletions .github/workflows/dotnet-webapp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: .NET WebApp Build

on:
push:
branches: [ develop, master ]
paths:
- 'WebApp/**/*'
pull_request:
branches: [ develop, master ]
paths:
- 'WebApp/**/*'

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore WebApp/
- name: Build
run: dotnet build WebApp/ --no-restore
- name: Test
run: dotnet test WebApp/ --no-build --verbosity normal
22 changes: 22 additions & 0 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This workflow will triage pull requests and apply a label based on the
# paths that are modified in the pull request.
#
# To use this workflow, you will need to set up a .github/labeler.yml
# file with configuration. For more information, see:
# https://github.com/actions/labeler

name: Labeler
on: [pull_request]

jobs:
label:

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- uses: actions/labeler@v2
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
9 changes: 0 additions & 9 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@ pipeline {
npm run-script build'''
}
}

stage('Deploy') {
steps {
sh '''cd ./WebApp
docker build -t registry.khaneliman.com/khaneliman/webapp:v0.01.00 .'''
sh '''cd ./WebApp
docker push registry.khaneliman.com/khaneliman/webapp:v0.01.00'''
}
}
}

post {
Expand Down
40 changes: 40 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Docker
# Build and push an image to Azure Container Registry
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker

trigger:
- master
- releases/*

resources:
- repo: self

variables:
# Container registry service connection established during pipeline creation
dockerRegistryServiceConnection: '532cafaa-016a-49e0-8d01-a12876fadc96'
imageRepository: 'khanelimanwebapp'
containerRegistry: 'khaneliman.azurecr.io'
dockerfilePath: '$(Build.SourcesDirectory)/WebApp/Dockerfile'
tag: '$(Build.BuildId)'

# Agent VM image name
vmImageName: 'ubuntu-latest'

stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
Loading

0 comments on commit d5fa200

Please sign in to comment.