Skip to content

Create main.yml

Create main.yml #1

Workflow file for this run

name: CI Pipeline
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
env:
GRADLE_USER_HOME: ${{ github.workspace }}/.gradle
steps:
- name: Checkout repository
uses: actions/checkout@v4.17
- name: Set up JDK
uses: actions/setup-java@v4.2.1
with:
distribution: 'jdk'
java-version: '21'
- name: Cache Gradle dependencies
uses: actions/cache@v4.0.2
with:
path: ${{ env.GRADLE_USER_HOME }}
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Run tests with Gradle
run: ./gradlew codeCoverageReport --build-cache --no-daemon
- name: Docker Login
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v3.2.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push Docker image
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v6.4.1
with:
context: .
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/qa-blog:latest