Skip to content

Commit

Permalink
Create main.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
tonylook authored Jul 19, 2024
1 parent 6f0a01c commit f920106
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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

0 comments on commit f920106

Please sign in to comment.