Github Actions contd
-
Pipeline
- When to run (on)
- Where to run (jobs => runs_on)
- what to run (jobs)
-
Github jobs execute on runners (servers on which jobs will be executed.) .
- Runners are of two types
- Github hosted Runners
- Gives you options to run the following
- These will have specific images
- Github gives us
- Standard Runners
- Linux (Ubuntu): 2 vCPUs, 7 GB RAM, 14 GB SSD storage.
- Windows: 2 vCPUs, 7 GB RAM, 14 GB SSD storage.
- macOS (Intel): 4 vCPUs, 14 GB RAM, 14 GB SSD storage.
- macOS (Apple Silicon – M1/M2): 3 vCPUs (M1), 7 GB RAM, 14 GB SSD storage. (Note: A 5-vCPU macOS M2 runner is also available in public preview).
- Large Runners
- Self hosted Runners
- Containers
jobs
- Jobs are collection of job elements which can be run in parallel or sequence
- A job runs on a runner
- job is made of steps
- Each step can be a
- low level command: are used with
run statement
- reusable action: are used with
withstatement. Github has a market place for actions
Lets try to build a java application
- SPring petclinic is a popular application developed in spring boot
- This application requires jdk 21 to run and maven to build it.
- the command to build the code
mvn package
sudo apt update
sudo apt install openjdk-21-jdk -y
cd /tmp
wget https://dlcdn.apache.org/maven/maven-3/3.9.11/binaries/apache-maven-3.9.11-bin.tar.gz
sudo tar xf apache-maven-3.9.11-bin.tar.gz -C /opt
# open maven.sh
sudo nano /etc/profile.d/maven.sh
# copy the following lines
export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
export M3_HOME=/opt/apache-maven-3.9.11
export MAVEN_HOME=/opt/apache-maven-3.9.11
export PATH=${M3_HOME}/bin:${PATH}
sudo chmod +x /etc/profile.d/maven.sh
source /etc/profile.d/maven.sh
mvn -version
- Clone the spring petclinic
git clone https://github.com/spring-projects/spring-petclinic.git
cd spring-petclinic
mvn package
---
on:
push:
branches:
- main
workflow_dispatch: #manual trigger
jobs:
maven:
runs-on: [ 'ubuntu-latest' ]
steps:
- name: checkout the code
uses: actions/checkout@v4
- name: build code
run: mvn package
Like this:
Like Loading...