Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

demo #114

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

demo #114

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# 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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

#
# ******** 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '22 19 * * 5'

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

strategy:
fail-fast: false
matrix:
language: [ 'java' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
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.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, 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@v2
- name: Build Java
run: |
mvn clean package -f tools/deploy/module2/pom.xml

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
78 changes: 78 additions & 0 deletions .github/workflows/mod4-lab1-deploy-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
on:
push:
branches:
- main
paths:
- 'tools/deploy/module4/*text*'
workflow_dispatch:

env:
TEST_AZURE_CONTAINER_REGISTRY: ${{ vars.TEST_AZURE_CONTAINER_REGISTRY }}
TEST_RESOURCE_GROUP: ${{ vars.TEST_RESOURCE_GROUP }}
TEST_CLUSTER_NAME: ${{ vars.TEST_CLUSTER_NAME }}
TEST_DEPLOYMENT_MANIFEST_PATH: ${{ vars.TEST_DEPLOYMENT_MANIFEST_PATH }}

permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
PushImagetoACR:
name: Push Sample Image to ACR and AKS
environment: test
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- name: Echo variables
run: |
echo "TEST_AZURE_CONTAINER_REGISTRY: ${{ env.TEST_AZURE_CONTAINER_REGISTRY }}";
echo "TEST_RESOURCE_GROUP: ${{ env.TEST_RESOURCE_GROUP }}";
echo "TEST_CLUSTER_NAME: ${{ env.TEST_CLUSTER_NAME }}";
echo "TEST_DEPLOYMENT_MANIFEST_PATH: ${{ env.TEST_DEPLOYMENT_MANIFEST_PATH }}"
# Checks out the repository this file is in
- uses: actions/checkout@v3

# Logs in with your Azure credentials
- name: Azure login
uses: azure/login@v1
with:
client-id: ${{ secrets.TEST_AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.TEST_AZURE_TENANT_ID }}
subscription-id: ${{ secrets.TEST_AZURE_SUBSCRIPTION_ID }}
# Pulling an image from Docker Hub to ACR. In a common CD scenario,
# the build and push of developed code would be part of a controlled workflow.
# The intention here is to show how environment variables and secrets work.
# So we will simplify the process.
- name: Pull a sample image from Docker hub to ACR
run: |
az acr import --name ${{ env.TEST_AZURE_CONTAINER_REGISTRY }} --source docker.io/library/nginx:latest --image nginx:latest -g ${{ env.TEST_RESOURCE_GROUP }}
continue-on-error: true
# Builds and pushes an image up to your Azure Container Registry
- name: Build and push image to ACR
run: |
echo "You could build and push an image to ACR here by using the following commented commands"
### az acr build --image "${{env.TEST_AZURE_CONTAINER_REGISTRY}}.azurecr.io/<your-repo-name>:${{ github.sha }}" -r "${{ env.TEST_AZURE_CONTAINER_REGISTRY }}" -g ${{ env.TEST_RESOURCE_GROUP }} .
- name: Checkout source code
uses: actions/checkout@v3
# Use kubelogin to configure your kubeconfig for Azure auth
- name: Set up kubelogin for non-interactive login
uses: azure/use-kubelogin@v1
with:
kubelogin-version: 'v0.0.25'
# Retrieves your Azure Kubernetes Service cluster's kubeconfig file
- name: Get K8s context
uses: azure/aks-set-context@v3
with:
resource-group: ${{ env.TEST_RESOURCE_GROUP }}
cluster-name: ${{ env.TEST_CLUSTER_NAME }}
admin: 'true'
use-kubelogin: 'true'
# Deploys application based on given manifest file
- name: Deploys application
uses: Azure/k8s-deploy@v4
with:
action: deploy
manifests: ${{ env.TEST_DEPLOYMENT_MANIFEST_PATH }}
images: |
${{ env.TEST_AZURE_CONTAINER_REGISTRY }}.azurecr.io/nginx:latest
2 changes: 2 additions & 0 deletions dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- package-ecosystem: "maven" # See documentation for possible values
directory: "/tools/deploy/module3" # Location of package manifests
2 changes: 1 addition & 1 deletion tools/deploy/module0/credential.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gha-oidc",
"issuer": "https://token.actions.githubusercontent.com",
"subject": "repo:<your-github-username>/AKS-DevSecOps-Workshop:ref:refs/heads/main",
"subject": "repo:vinod-soni-microsoft/AKS-DevSecOps-Workshop:ref:refs/heads/main",
"audiences": ["api://AzureADTokenExchange"],
"description": "Workload Identity for AKS DevSecOps repo - branch mod 4"
}
2 changes: 1 addition & 1 deletion tools/deploy/module4/mod4-credential.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gha-mod4-oidc",
"issuer": "https://token.actions.githubusercontent.com",
"subject": "repo:msmarti/AKS-DevSecOps-Workshop:environment:test",
"subject": "repo:vinod-soni-microsoft/AKS-DevSecOps-Workshop:environment:test",
"audiences": ["api://AzureADTokenExchange"],
"description": "Workload Identity for AKS DevSecOps repo - Mod 4"
}
4 changes: 3 additions & 1 deletion tools/deploy/module4/text.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
a

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

some comments
some comments
some comments