Github expressions
Conditions in Github actions
- Watch classroom video and actions over here
loops
- View the following workflow
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-java-with-maven
name: Java CI with Maven
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java-version: [ '17', '21' ]
steps:
- name: Print Github Context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: "echo ${GITHUB_CONTEXT}"
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: 'adopt'
cache: maven
- name: Build with Maven Wrapper
run: ./mvnw package
Github workflow triggers
- Events that trigger workflows
- Manually run a workflow
- Workflow call is when one workflow is called by other which is generally reusing workflows Refer Here
Continuous Integration
* Watch classroom recording for codeql scans
* Exercise: Try setting up a sonar cloud workflow with your public springpetclinic
