diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f9e5b74 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,60 @@ +name: Build & Push + +on: + push: + branches: + - main + pull_request: + branches: + - main + +# cancel workflow if there is already one running +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3.0.0 + - name: Set up JDK 17 + uses: actions/setup-java@v3.0.0 + with: + java-version: 17 + distribution: liberica + - name: Build plugin + run: ./gradlew buildPlugin + working-directory: ide-former-plugin + + # build docker container + docker: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3.0.0 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }} + platforms: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' && 'linux/amd64,linux/arm64' || 'linux/amd64' }} + tags: ghcr.io/${{ github.repository }}/runner:latest,ghcr.io/${{ github.repository }}/runner:${{ github.sha }} + cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/runner:latest + + + + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1855ef5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +FROM ubuntu:20.04 + +# Install Java +RUN apt-get update && apt-get install -y \ + openjdk-17-jdk \ + && java -version + +# Install Git +RUN apt-get install -y \ + git \ + && git --version + +# Install Python3 and pip3 +RUN apt-get update && apt-get install -y \ + python3 \ + python3-pip \ + python3-setuptools \ + python3-wheel \ + && python3 --version + +# Disable gradle daemon +ENV GRADLE_OPTS "-Dorg.gradle.daemon=false" + +# Copy the plugin +COPY ide-former-plugin /ide-former-plugin + +# prebuild the plugin with gradle +RUN cd /ide-former-plugin && ./gradlew buildPlugin + +ENTRYPOINT ["bash", "/ide-former-plugin/runPluginStarter.sh"] + +CMD [] \ No newline at end of file diff --git a/ide-former-plugin/.github/workflows/build.yml b/ide-former-plugin/.github/workflows/build.yml deleted file mode 100644 index d92b382..0000000 --- a/ide-former-plugin/.github/workflows/build.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Gradle Build - -on: [push, pull_request] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3.0.0 - - name: Set up JDK 17 - uses: actions/setup-java@v3.0.0 - with: - java-version: 17 - distribution: liberica - - name: Gradle Wrapper Validation - uses: gradle/wrapper-validation-action@v1.0.4 - - uses: gradle/gradle-build-action@v2.1.5 - with: - arguments: build --stacktrace diff --git a/ide-former-plugin/runPluginStarter.sh b/ide-former-plugin/runPluginStarter.sh index 72595fd..53e18c4 100755 --- a/ide-former-plugin/runPluginStarter.sh +++ b/ide-former-plugin/runPluginStarter.sh @@ -7,4 +7,40 @@ if uname -s | grep -iq cygwin ; then PWD=$(cygpath -w "$PWD") fi -"$DIR/gradlew" -p "$DIR" runIdeAssistantPlugin -Prunner=ide-server -PpathToProject="$1" -PserverHost="$2" -PserverPort="$3" \ No newline at end of file +# check number of arguments +if [ $# -gt 3 ]; then + echo "Illegal number of parameters" + echo "Usage: runPluginStarter.sh " + echo "\t - path to the project to be opened in IDE, default is the plugin itself" + echo "\t - host of the server to connect to, default is localhost" + echo "\t - port of the server to connect to, default is 8080" + echo "" + echo "Examples:" + echo "\t./runPluginStarter.sh /project" + echo "\t./runPluginStarter.sh /project localhost 9080" + exit 1 +fi + +# set default values +if [ -z "$1" ]; then + echo "No path to project specified. Using the plugin itself at $DIR" + PATH_TO_PROJECT="$DIR" +else + PATH_TO_PROJECT=$1 +fi + +if [ -z "$2" ]; then + echo "No server host specified. Using 127.0.0.1" + SERVER_HOST="127.0.0.1" +else + SERVER_HOST=$2 +fi + +if [ -z "$3" ]; then + echo "No server port specified. Using 8080" + SERVER_PORT="8080" +else + SERVER_PORT=$3 +fi + +"$DIR/gradlew" -p "$DIR" runIdeAssistantPlugin -Prunner=ide-server -PpathToProject="$PATH_TO_PROJECT" -PserverHost="$SERVER_HOST" -PserverPort="$SERVER_PORT" \ No newline at end of file