Skip to content

Add Docker-based GitHub Action draft #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions .github/workflows/mvn-ci.yml → .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: MVN-CI
name: Build CI

on:
push:
Expand All @@ -12,7 +12,7 @@ on:
- 'v*.*.*'

jobs:
build:
build-java:
runs-on: [ubuntu-24.04]

steps:
Expand Down Expand Up @@ -45,3 +45,28 @@ jobs:
with:
name: release-to-issue-jar-with-dependencies.jar
path: release-to-issue-java/target/release-to-issue-java-*-jar-with-dependencies.jar

build-docker:
runs-on: [ubuntu-24.04]
needs: [build-java]

steps:
# Set up
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# - name: Download executable JAR
# uses: actions/download-artifact@v4
# with:
# name: release-to-issue-jar-with-dependencies.jar

# Build Docker image
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
push: false
tags: maxkratz/release-to-issue
platforms: linux/amd64,linux/arm64
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Build the application within Docker
FROM maven:3.9.9-eclipse-temurin-21 AS build
WORKDIR /app
COPY release-to-issue-java/pom.xml .
COPY release-to-issue-java/src ./src
RUN mvn clean compile assembly:single -DskipTests

# Base image and maintainer
FROM openjdk:17
LABEL maintainer="Max Kratz <[email protected]>"

COPY --from=build /app/target/release-to-issue-java-*-jar-with-dependencies.jar .

# Copy and define the entrypoint script
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
39 changes: 39 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# action.yml
name: 'Release to issue'
description: 'Create a new issue in your GitHub repository based on new releases of other GitHub repositories.'
inputs:
source-repo:
description: 'Which repo to check for new releases'
required: true
default: 'maxkratz/release-to-issue-docker-action'
target-repo:
description: 'Which repo to check for new releases'
required: true
start-date:
description: 'Date limit to ignore older releases'
required: true
default: '2025-01-01'
assignee-name:
description: 'Which GitHub user should be assigned to newly created issues'
required: true
github-username:
description: 'Which GitHub user should be used to query the GitHub API'
required: true
github-token:
description: 'Which GitHub token should be used to query the GitHub API'
required: true
dry-run:
description: 'If true, the Action will not create any issues but just simulate them'
require: false
default: false
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.source-repo }}
- ${{ inputs.target-repo }}
- ${{ inputs.start-date }}
- ${{ inputs.assignee-name }}
- ${{ inputs.github-username }}
- ${{ inputs.github-token }}
- ${{ inputs.dry-run }}
38 changes: 38 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

set -e

# Give the arguments nice variable names
SOURCE_REPO=$1
TARGET_REPO=$2
START_DATE=$3
ASSIGNEE=$4
GITHUB_USERNAME=$5
GITHUB_TOKEN=$6
DRY_RUN=$7

# Output dry run value
if [ -z ${DRY_RUN} ]; then
DRY_RUN=0
fi
echo "Dry run: $DRY_RUN"

# Create tmp file with GitHub credentials
echo "login=$GITHUB_USERNAME" > /github.properties
echo "password=$GITHUB_TOKEN" > /github.properties

# Determin JAR file name
JAR=release-to-issue-java-*-jar-with-dependencies.jar

# Run Java program
if [ "$DRY_RUN" -eq "1" ]; then
echo "Running dry."
java -jar $JAR --sourcerepo $SOURCE_REPO --targetrepo $TARGET_REPO --datelimit $START_DATE --assignee $ASSIGNEE --dryrun
else
echo "Running wet."
java -jar $JAR --sourcerepo $SOURCE_REPO --targetrepo $TARGET_REPO --datelimit $START_DATE --assignee $ASSIGNEE
fi

# Delete tmp file with GitHub credentials
rm -f /github.properties
exit 0
Loading