Skip to content

Commit

Permalink
Updating pr actions
Browse files Browse the repository at this point in the history
Signed-off-by: dwertent <[email protected]>
  • Loading branch information
dwertent committed Sep 18, 2024
1 parent eb7be4f commit d036466
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Paladin CI build
name: build

on:
push:
branches: [main]
pull_request:
workflow_dispatch:
inputs:
ARTIFACTS_PATH:
required: false
type: string
default: build/libs

jobs:
build:
Expand Down Expand Up @@ -38,6 +40,16 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
add-job-summary-as-pr-comment: on-failure

- name: Build with Gradle
run: ./gradlew -PcomposeLogs=true -PverboseTests=true -PjarVersion=v0.0.0 --no-daemon --parallel
run: ./gradlew -PcomposeLogs=true -PverboseTests=true --no-daemon --parallel

- uses: actions/upload-artifact@v4
name: Upload build artifacts
with:
name: paladin-libs
path: ${{ inputs.ARTIFACTS_PATH }}
if-no-files-found: error

65 changes: 65 additions & 0 deletions .github/workflows/image-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: build

on:
workflow_dispatch:
inputs:
IMAGE_REGISTRY:
required: false
description: 'image registry'
default: ''
IMAGE_NAME:
required: false
description: 'Name of the image to build'
default: 'paladin'
IMAGE_TAG:
required: false
description: 'Version of the image to build'
default: 'latest'
BUILD_PLATFORM:
required: false
description: 'Platform to build the image for'
default: 'linux/amd64'
# default: 'linux/amd64,linux/arm64'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive

- uses: actions/download-artifact@v4
name: Download build artifacts
with:
name: paladin-libs
path: build/libs/
if-no-files-found: error

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# TODO: Setup docker registry
# - name: Login to Docker registry
# if: ${{ inputs.IMAGE_REGISTRY != '' }}
# uses: docker/login-action@v3
# with:
# registry: ${{ inputs.IMAGE_REGISTRY }}
# username: ${{ secrets.REGISTRY_USERNAME }}
# password: ${{ secrets.REGISTRY_PASSWORD }}

- name: Build
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
tags: ${{ inputs.IMAGE_REGISTRY }}/${{ inputs.IMAGE_NAME }}:${{ inputs.IMAGE_TAG }}
build-args: image_version=${{ inputs.IMAGE_TAG }}
platforms: ${{ inputs.BUILD_PLATFORM }}
cache-from: type=gha
cache-to: type=gha,mode=max
push: false
62 changes: 62 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: PR
permissions: read-all
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
paths-ignore:
- '**.sh'
- 'docs/*'
- 'build/*'
- '.github/*'
# - '**.md' // Uncomment this line to ignore all markdown files

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test-and-build:
permissions:
actions: read
checks: read
deployments: read
id-token: write
issues: read
discussions: read
packages: read
pages: read
pull-requests: write
repository-projects: read
security-events: read
statuses: read
attestations: read
contents: write
uses: ./.github/workflows/build.yaml
secrets: inherit
with:
ARTIFACTS_PATH: buils/libs

build-image:
permissions:
actions: read
checks: read
contents: write
deployments: read
discussions: read
id-token: write
issues: read
packages: write
pages: read
pull-requests: read
repository-projects: read
security-events: read
statuses: read
attestations: read
uses: ./.github/workflows/image-build.yaml
with:
ARTIFACTS_PATH: buils/libs
IMAGE_NAME: paladin
IMAGE_TAG: pr-test
BUILD_PLATFORM: linux/amd64

secrets: inherit
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM ubuntu:24.04

# Install Java (JRE only) and other necessary dependencies
RUN apt-get update && \
apt-get install --no-install-recommends -y openjdk-21-jre-headless && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /app

# Copy the JAR file and necessary libraries
COPY build/libs/ libs/

# placehoolder: expose ports
# EXPOSE <port>

# placehoolder: entrypoint
# ENTRYPOINT ["paladin"]

# Run the JAR file
# Override this with `docker run --entrypoint`
ENTRYPOINT ["java", "-Djna.library.path=/app/libs", "-jar", "app/libs/paladin.jar"]

# Default command-line arguments (config file and node name)
# Override this with docker run <image> /app/other-config.yaml another-node

CMD ["app/config.paladin.yaml", "node"]

# Override the default command-line arguments
# docker run -d -p <>:<> \
# -v <path to config file on host>:<path to config file> \
# <image> \
# -Djna.library.path=/app \
# -jar paladin.jar <path to config file> <node name>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@ defaultTasks 'build', 'copyExecutables'

// Clean task to clean all projects
task clean {
delete 'build'
delete "${buildDir}"
}

0 comments on commit d036466

Please sign in to comment.