diff --git a/.github/workflows/all-matrix.yml b/.github/workflows/all-matrix.yml new file mode 100644 index 00000000..6e58244c --- /dev/null +++ b/.github/workflows/all-matrix.yml @@ -0,0 +1,83 @@ +name: All Matrix Use Cases + +on: + workflow_dispatch: + +jobs: + + # Use Case 1: + basic-matrix: + name: "Basic Matrix: ${{ matrix.os }} - Java ${{ matrix.java }}" + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + java: [17, 20] + steps: + - name: Echo basic combo + run: | + echo "OS=${{ matrix.os }}, Java=${{ matrix.java }}" + + # Use Case 2: + include-matrix: + name: "Include Matrix: ${{ matrix.os }} - Java ${{ matrix.java }}" + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + java: 17 + - os: windows-latest + java: 20 + steps: + - name: Echo included pair + run: | + echo "Included pair: ${{ matrix.os }} - ${{ matrix.java }}" + + # Use Case 3: + exclude-matrix: + name: "Exclude Matrix: ${{ matrix.os }} - Java ${{ matrix.java }}" + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + java: [17, 20] + exclude: + - os: windows-latest + java: 20 + steps: + - name: Echo allowed pair + run: | + echo "Allowed pair: ${{ matrix.os }} - ${{ matrix.java }}" + + # Use Case 4: + custom-key-matrix: + name: "Custom Key Matrix: ${{ matrix.os }} - Mode ${{ matrix.mode }}" + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + java: 17 + mode: dev + - os: windows-latest + java: 20 + mode: prod + steps: + - name: Echo custom-mode combo + run: | + echo "Running in ${{ matrix.mode }} mode with Java ${{ matrix.java }} on ${{ matrix.os }}" + + # Use Case 5: + failfast-matrix: + name: "Fail-Fast Off Matrix: ${{ matrix.env }}" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + env: [alpha, beta, prod] + steps: + - name: Simulate environment + run: | + echo "Running environment: ${{ matrix.env }}" + if [[ "${{ matrix.env }}" == "beta" ]]; then exit 1; fi diff --git a/.github/workflows/basic-matrix.yml b/.github/workflows/basic-matrix.yml new file mode 100644 index 00000000..f891625c --- /dev/null +++ b/.github/workflows/basic-matrix.yml @@ -0,0 +1,14 @@ +name: Basic Matrix + +on: + workflow_dispatch: + +jobs: + basic-matrix: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + java: [17, 20] + steps: + - run: echo "OS=${{ matrix.os }}, Java=${{ matrix.java }}" diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 0cea9618..b0f2663f 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -1,153 +1,58 @@ -name: CICD Pipeline +# File: .github/workflows/ci.yml +name: CI Pipeline on: + # 1) Pushes to main push: - branches: [ "main" ] + branches: + - main + paths-ignore: + - 'docs/**' + - '**/*.md' + - '**/*.txt' + # 2) Issue events (opened & edited) + issues: + types: + - opened + - edited + # 3) Pull requests (opened & new commits) + pull_request: + branches: + - main + types: + - opened + - synchronize + # 4) Manual dispatch with an environment input + workflow_dispatch: + inputs: + environment: + description: 'Which environment to deploy to' + required: true + default: 'staging' jobs: - compile: - runs-on: self-hosted - - steps: - - uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - cache: maven - - name: Build with Maven - run: mvn compile - - security-check: - runs-on: self-hosted - needs: compile - + build: + name: Build + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Trivy Installation - run: | - sudo apt-get install -y wget apt-transport-https gnupg lsb-release - wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add - - echo deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | sudo tee -a /etc/apt/sources.list.d/trivy.list - sudo apt-get update -y - sudo apt-get install -y trivy - - - name: Trivy FS Scan - run: trivy fs --format table -o fs-report.json . - - - name: Gitleaks Installation - run: sudo apt install gitleaks -y - - name: Gitleaks Code Scan - run: gitleaks detect source . -r gitleaks-report.json -f json + - uses: actions/checkout@v4 + - name: Print Build + run: echo "Building for ${{ github.event_name }} event" test: - runs-on: self-hosted - needs: security-check + name: Test + runs-on: windows-latest steps: - - uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - cache: maven - - name: Unit Test Cases - run: mvn test - - build_project_and_sonar_scan: - runs-on: self-hosted - needs: test + - uses: actions/checkout@v4 + - name: Print Test + run: echo "Testing on ${{ runner.os }} via ${{ github.event_name }}" + + deploy: + name: Deploy + runs-on: ubuntu-latest + if: ${{ github.event_name != 'issues' }} # optional: skip deploy on issue events steps: - - uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - cache: maven - - name: Build Project - run: mvn package - - name: Upload JAR artifact - uses: actions/upload-artifact@v4 - with: - name: app-jar - path: target/*.jar - - - uses: actions/checkout@v4 - with: - # Disabling shallow clones is recommended for improving the relevancy of reporting - fetch-depth: 0 - - name: SonarQube Scan - uses: SonarSource/sonarqube-scan-action@v5.0.0 # Ex: v4.1.0, See the latest version at https://github.com/marketplace/actions/official-sonarqube-scan - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }} - - - name: SonarQube Quality Gate check - id: sonarqube-quality-gate-check - uses: sonarsource/sonarqube-quality-gate-action@master - with: - pollingTimeoutSec: 600 - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }} - - buils_docker_image_and_push: - runs-on: self-hosted - needs: build_project_and_sonar_scan - steps: - - uses: actions/checkout@v4 - - name: Download JAR artifact - uses: actions/download-artifact@v4 - with: - name: app-jar - path: app # this will download JAR to ./app folder - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ vars.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Build and Push Docker image - uses: docker/build-push-action@v6 - with: - context: . - push: true - tags: adijaiswal/bankapp:latest - file: ./Dockerfile - - deploy_to_kubernetes: - runs-on: self-hosted - needs: buils_docker_image_and_push - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - name: Install AWS CLI - run: | - curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" - unzip awscliv2.zip - sudo ./aws/install - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ap-south-1 - - name: Set up kubectl - uses: azure/setup-kubectl@v3 - with: - version: latest - - name: Configure kubeconfig - run: | - mkdir -p $HOME/.kube - echo "${{ secrets.EKS_KUBECONFIG }}" > $HOME/.kube/config - - name: Deploy to EKS - run: | - kubectl apply -f ds.yml - - + - uses: actions/checkout@v4 + - name: Print Deploy + run: | + echo "Deploying to ${{ github.event.inputs.environment || 'default' }}" diff --git a/.github/workflows/combo.yml b/.github/workflows/combo.yml new file mode 100644 index 00000000..23f2b01c --- /dev/null +++ b/.github/workflows/combo.yml @@ -0,0 +1,23 @@ +name: 6 Combine Env Vars Secrets + +on: + workflow_dispatch: + +env: # Workflow-level env + GLOBAL_ENV: workflow-env + +jobs: + combo-demo: + runs-on: ubuntu-latest + + env: # Job-level env (can override workflow-level) + GLOBAL_ENV: job-env + + steps: + - name: Print everything + run: | + echo "env.GLOBAL_ENV = ${{ env.GLOBAL_ENV }}" + echo "vars.MY_VAR = ${{ vars.MY_VAR }}" + echo "secrets.MY_SECRET = ${{ secrets.MY_SECRET }}" + env: + GLOBAL_ENV: step-env diff --git a/.github/workflows/consume-info.yml b/.github/workflows/consume-info.yml new file mode 100644 index 00000000..3757ae60 --- /dev/null +++ b/.github/workflows/consume-info.yml @@ -0,0 +1,19 @@ +name: Consume Generated Info + +on: + workflow_dispatch: + +jobs: + # Call the reusable workflow + call-generate: + uses: ./.github/workflows/generate-info.yml + + # Consume its outputs + consumer: + needs: call-generate + runs-on: ubuntu-latest + steps: + - name: Show the values + run: | + echo "Timestamp: ${{ needs.call-generate.outputs.current-time }}" + echo "Random number: ${{ needs.call-generate.outputs.random-number }}" diff --git a/.github/workflows/env-hierarchy.yml b/.github/workflows/env-hierarchy.yml new file mode 100644 index 00000000..8c9e9fde --- /dev/null +++ b/.github/workflows/env-hierarchy.yml @@ -0,0 +1,20 @@ +name: Env Override Levels - UC 2 + +on: + workflow_dispatch: + +env: + LEVEL: workflow + +jobs: + env-test: + runs-on: ubuntu-latest + + env: + LEVEL: job + + steps: + - name: Print env + run: echo "env.LEVEL = ${{ env.LEVEL }}" + env: + LEVEL: step diff --git a/.github/workflows/env-or-vars.yml b/.github/workflows/env-or-vars.yml new file mode 100644 index 00000000..9c9d5d89 --- /dev/null +++ b/.github/workflows/env-or-vars.yml @@ -0,0 +1,18 @@ +name: Fallback Env or Vars - Uc 4 + +on: + workflow_dispatch: + +jobs: + fallback-demo: + runs-on: ubuntu-latest + + steps: + - name: Step 1 – No env set (should fallback to vars) + run: echo "Value = ${{ env.MY_VAR || vars.MY_VAR }}" + + - name: Step 2 – Env set (should override vars) + run: echo "Value = ${{ env.MY_VAR || vars.MY_VAR }}" + env: + MY_VAR: from-env + diff --git a/.github/workflows/environment-variables.yml b/.github/workflows/environment-variables.yml new file mode 100644 index 00000000..5b2d03e1 --- /dev/null +++ b/.github/workflows/environment-variables.yml @@ -0,0 +1,19 @@ +name: Variable Demo + +on: + workflow_dispatch: + +jobs: + print-vars: + runs-on: ubuntu-latest + + env: + MY_VAR: job-level + + steps: + - name: Print env and vars + run: | + echo "env.MY_VAR = ${{ env.MY_VAR }}" + echo "vars.MY_VAR = ${{ vars.MY_VAR }}" + env: + MY_VAR: step-level diff --git a/.github/workflows/generate-info.yml b/.github/workflows/generate-info.yml new file mode 100644 index 00000000..b6688056 --- /dev/null +++ b/.github/workflows/generate-info.yml @@ -0,0 +1,29 @@ +name: Outputs - Generate + +on: + workflow_call: + outputs: + current-time: + description: 'Current timestamp (UTC)' + value: ${{ jobs.generate.outputs.current-time }} + random-number: + description: 'Random number from shell' + value: ${{ jobs.generate.outputs.random-number }} + +jobs: + generate: + runs-on: ubuntu-latest + + # Expose step outputs as job outputs + outputs: + current-time: ${{ steps.get-time.outputs.time }} + random-number: ${{ steps.get-random.outputs.number }} + + steps: + - id: get-time + run: | + echo "time=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT + + - id: get-random + run: | + echo "number=$RANDOM" >> $GITHUB_OUTPUT diff --git a/.github/workflows/github-context-conditions.yml b/.github/workflows/github-context-conditions.yml new file mode 100644 index 00000000..17846d51 --- /dev/null +++ b/.github/workflows/github-context-conditions.yml @@ -0,0 +1,38 @@ +name: GitHub Context with Conditions + +on: + workflow_dispatch: + push: + branches: + - main + pull_request: + types: [opened, synchronize] + +jobs: + show-github-context: + runs-on: ubuntu-latest + steps: + + - name: Checkout code + uses: actions/checkout@v3 + + - name: print basic repo info + run: | + echo "Repository: ${{ github.repository }}" + echo "Workflow: ${{ github.workflow }}" + + - name: Print branch or tag (only on push) + if: ${{ github.event_name == 'push' }} + run: | + echo "Ref: ${{ github.ref }}" + echo "Branch/Tag: ${{ github.ref_name }}" + + - name: Print server & API URLs (only on manual dispatch) + if: ${{ github.event_name == 'workflow_dispatch' }} + run: | + echo "Server URL: ${{ github.server_url }}" + echo "API URL: ${{ github.api_url }}" + + - name: Deploy notice (only on main branch push) + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + run: echo "Deploy step would run now..." diff --git a/.github/workflows/githubcontext.yml b/.github/workflows/githubcontext.yml new file mode 100644 index 00000000..ab6ceebc --- /dev/null +++ b/.github/workflows/githubcontext.yml @@ -0,0 +1,26 @@ +name: GitHub Context + +on: + workflow_dispatch: + +jobs: + show-github-context: + runs-on: ubuntu-latest + steps: + - name: Print Info about GitHub Context + run: | + echo "Repository: ${{ github.repository }}" + echo "Repository ID: ${{ github.repository_id }}" + echo "Repository URL: ${{ github.repositoryUrl }}" + echo "Server URL: ${{ github.server_url }}" + echo "API URL: ${{ github.api_url }}" + echo "GraphQL URL: ${{ github.graphql_url }}" + echo "Workflow: ${{ github.workflow }}" + echo "Ref: ${{ github.ref }}" + echo "Event Name: ${{ github.event_name }}" + echo "SHA: ${{ github.sha }}" + echo "Run ID: ${{ github.run_id }}" + echo "Run Number: ${{ github.run_number }}" + echo "Job: ${{ github.job }}" + echo "Actor: ${{ github.actor }}" + echo "Workspace: ${{ github.workspace }}" diff --git a/.github/workflows/indexed-matrix.yml b/.github/workflows/indexed-matrix.yml new file mode 100644 index 00000000..d5599d74 --- /dev/null +++ b/.github/workflows/indexed-matrix.yml @@ -0,0 +1,32 @@ +# .github/workflows/indexed-matrix.yml +name: Indexed Matrix + +on: + workflow_dispatch: + +jobs: + indexed-matrix: + name: "Indexed Matrix: #${{ matrix.index }}" + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + java: 17 + index: 1 + - os: ubuntu-latest + java: 20 + index: 2 + - os: windows-latest + java: 17 + index: 3 + - os: windows-latest + java: 20 + index: 4 + + steps: + - name: Echo index & combo + run: | + echo "Index = ${{ matrix.index }}" + echo "OS = ${{ matrix.os }}" + echo "Java = ${{ matrix.java }}" diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml new file mode 100644 index 00000000..5ac8dc4e --- /dev/null +++ b/.github/workflows/java.yml @@ -0,0 +1,24 @@ +name: Java Setup + +on: + workflow_dispatch: + +jobs: + java-setup: + runs-on: ubuntu-latest + + steps: + # 1. Check out your repository + - name: Checkout code + uses: actions/checkout@v3 + + # 2. Set up JDK 21 (Microsoft Build of OpenJDK) + - name: Set up JDK 21 + uses: actions/setup-java@v3 + with: + distribution: microsoft + java-version: '21' + + # 3. Print the installed Java version + - name: Print Java Version + run: java -version diff --git a/.github/workflows/matrix-max-parallel.yml b/.github/workflows/matrix-max-parallel.yml new file mode 100644 index 00000000..062fb37c --- /dev/null +++ b/.github/workflows/matrix-max-parallel.yml @@ -0,0 +1,33 @@ +# .github/workflows/indexed-matrix.yml +name: Matrix Max Parallel 2 + +on: + workflow_dispatch: + +jobs: + indexed-matrix: + name: "Indexed Matrix: #${{ matrix.index }}" + runs-on: ${{ matrix.os }} + strategy: + max-parallel: 2 # ← limit to 2 concurrent jobs + matrix: + include: + - os: ubuntu-latest + java: 17 + index: 1 + - os: ubuntu-latest + java: 20 + index: 2 + - os: windows-latest + java: 17 + index: 3 + - os: windows-latest + java: 20 + index: 4 + + steps: + - name: Echo index & combo + run: | + echo "Index = ${{ matrix.index }}" + echo "OS = ${{ matrix.os }}" + echo "Java = ${{ matrix.java }}" diff --git a/.github/workflows/matrix.yml b/.github/workflows/matrix.yml new file mode 100644 index 00000000..13567cd9 --- /dev/null +++ b/.github/workflows/matrix.yml @@ -0,0 +1,26 @@ +name: Matrix + +on: + workflow_dispatch: + +jobs: + matrix-jobs: + name: Matrix Job - ${{ matrix.os }} - Java ${{ matrix.java-version }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + java-version: [17, 20] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Java JDK ${{ matrix.java-version }} + uses: actions/setup-java@v3.14.1 + with: + java-version: ${{ matrix.java-version }} + distribution: temurin + + - name: Verify Java version + run: java -version diff --git a/.github/workflows/multi-job-vars.yml b/.github/workflows/multi-job-vars.yml new file mode 100644 index 00000000..acc9fac0 --- /dev/null +++ b/.github/workflows/multi-job-vars.yml @@ -0,0 +1,17 @@ +name: Multi Job Vars - Uc 5 + +on: + workflow_dispatch: + +jobs: + job-one: + runs-on: ubuntu-latest + steps: + - name: Use MY_VAR in Job 1 + run: echo "Job 1 value = ${{ vars.MY_VAR }}" + + job-two: + runs-on: ubuntu-latest + steps: + - name: Use MY_VAR in Job 2 + run: echo "Job 2 value = ${{ vars.MY_VAR }}" diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml new file mode 100644 index 00000000..34d84955 --- /dev/null +++ b/.github/workflows/node.yml @@ -0,0 +1,23 @@ +name: Node Js Setup + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + # 1. Checkout Your Repo + - name: Checkout code + uses: actions/checkout@v3 + + # 2. Setup Node.js + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "18" + + # 3. Verify Node Version + - name: Print Node.js Version + run: node --version diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 00000000..a4ce5156 --- /dev/null +++ b/.github/workflows/python.yml @@ -0,0 +1,23 @@ +name: Python Setup + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + # 1. Check out your repository + - name: Checkout code + uses: actions/checkout@v3 + + # 2. Set up Python (uses actions/setup-python) + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' # pick a specific version like '3.11' if you prefer + + # 3. Verify Python version (optional) + - name: Print Python version + run: python --version diff --git a/.github/workflows/secrets.yml b/.github/workflows/secrets.yml new file mode 100644 index 00000000..6fb66339 --- /dev/null +++ b/.github/workflows/secrets.yml @@ -0,0 +1,12 @@ +name: Secrets - UC 3 + +on: + workflow_dispatch: + +jobs: + secret-test: + runs-on: ubuntu-latest + + steps: + - name: Print secret (masked in logs) + run: echo "secrets.MY_SECRET = ${{ secrets.MY_SECRET }}" diff --git a/.github/workflows/total-matrix.yml b/.github/workflows/total-matrix.yml new file mode 100644 index 00000000..48619910 --- /dev/null +++ b/.github/workflows/total-matrix.yml @@ -0,0 +1,36 @@ +# .github/workflows/indexed-total-matrix.yml +name: Total Matrix + +on: + workflow_dispatch: + +jobs: + combo-matrix: + name: "Combo ${{ matrix.index }} of ${{ matrix.total }}" + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + java: 17 + index: 1 + total: 4 + - os: ubuntu-latest + java: 20 + index: 2 + total: 4 + - os: windows-latest + java: 17 + index: 3 + total: 4 + - os: windows-latest + java: 20 + index: 4 + total: 4 + + steps: + - name: Echo position & combo + run: | + echo "Job ${{ matrix.index }} of ${{ matrix.total }}" + echo "OS = ${{ matrix.os }}" + echo "Java = ${{ matrix.java }}" diff --git a/.github/workflows/vars.yml b/.github/workflows/vars.yml new file mode 100644 index 00000000..22376263 --- /dev/null +++ b/.github/workflows/vars.yml @@ -0,0 +1,12 @@ +name: Vars - UC 1 + +on: + workflow_dispatch: + +jobs: + demo-vars: + runs-on: ubuntu-latest + + steps: + - name: Print MY_VAR from vars + run: echo "vars.MY_VAR = ${{ vars.MY_VAR }}" diff --git a/filecm b/filecm new file mode 100644 index 00000000..e69de29b diff --git a/g1 b/g1 new file mode 100644 index 00000000..e69de29b diff --git a/githubcontext b/githubcontext new file mode 100644 index 00000000..4987775e --- /dev/null +++ b/githubcontext @@ -0,0 +1 @@ +this a github commit diff --git a/mdtest b/mdtest new file mode 100644 index 00000000..dfdfb43d --- /dev/null +++ b/mdtest @@ -0,0 +1 @@ +pull request github actions diff --git a/test b/test new file mode 100644 index 00000000..ad62b129 --- /dev/null +++ b/test @@ -0,0 +1 @@ +test push............ diff --git a/testpullopenstatus b/testpullopenstatus new file mode 100644 index 00000000..1f81c988 --- /dev/null +++ b/testpullopenstatus @@ -0,0 +1 @@ +test pull open status