From a40e21db60020a79dce8e534bbcd38c7dce2de8e Mon Sep 17 00:00:00 2001 From: Sean Greenawalt Date: Fri, 19 Sep 2025 17:14:03 -0400 Subject: [PATCH] Add workflow directly to the repo --- .forgejo/workflows/publish-patch.yaml | 85 +++++++++++++++++++++++++++ patches/workflow.patch | 76 ------------------------ 2 files changed, 85 insertions(+), 76 deletions(-) create mode 100644 .forgejo/workflows/publish-patch.yaml delete mode 100644 patches/workflow.patch diff --git a/.forgejo/workflows/publish-patch.yaml b/.forgejo/workflows/publish-patch.yaml new file mode 100644 index 0000000..3ecc7d9 --- /dev/null +++ b/.forgejo/workflows/publish-patch.yaml @@ -0,0 +1,85 @@ +name: Build and Patch Releases + +on: + schedule: + - cron: '30 17 * * *' # Runs daily at 5:30 PM + +jobs: + build: + runs-on: docker + container: + image: ghcr.io/catthehacker/ubuntu:act-22.04 + + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Clone Stirling-PDF Repository + run: | + git clone https://github.com/Stirling-Tools/Stirling-PDF.git + cd Stirling-PDF + latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) + echo "latest_tag=$latest_tag" >> $GITHUB_ENV + git checkout $latest_tag + + - name: Compare with Latest Published Tag + run: | + latest_published_tag=$(curl -s -u ${{ secrets.TOKEN }} https://git.spgrn.com/v2/_catalog | jq -r '.repositories[]' | grep -oP 'stirling-pdf:\K.*' | sort -V | tail -1 || echo "") + echo "latest_published_tag=$latest_published_tag" >> $GITHUB_ENV + + if [ -z "$latest_published_tag" ]; then + echo "No published tag found. Proceeding with the build." + elif [ "$latest_tag" = "$latest_published_tag" ]; then + echo "Image already exists. Exiting." + exit 0 + fi + + - name: Apply Patches + run: | + cd Stirling-PDF + git am ../patches/*.patch + + - name: Set up JDK 17 + uses: https://github.com/actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0 + with: + java-version: "17" + distribution: "temurin" + + - uses: https://github.com/gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4.3.0 + with: + gradle-version: 8.12 + + - name: Run Gradle Command + run: ./gradlew clean build + env: + DOCKER_ENABLE_SECURITY: false + + - name: Login to Container Registry + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 + with: + registry: git.spgrn.com + username: seang96 + password: ${{ secrets.TOKEN }} + + - name: Generate tags fat + id: meta3 + uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1 + with: + images: | + git.spgrn.com/${{ github.repository_owner }}/s-pdf + git.spgrn.com/${{ github.repository_owner }}/stirling-pdf + tags: | + type=raw,value=${{ env.latest_tag }}-fat + type=raw,value=latest-fat + + - name: Build and push main Dockerfile fat + id: build-push-fat + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile.fat + push: true + tags: ${{ steps.meta3.outputs.tags }} + labels: ${{ steps.meta3.outputs.labels }} + build-args: VERSION_TAG=${{ env.latest_tag }} + platforms: linux/amd64 \ No newline at end of file diff --git a/patches/workflow.patch b/patches/workflow.patch deleted file mode 100644 index 954274e..0000000 --- a/patches/workflow.patch +++ /dev/null @@ -1,76 +0,0 @@ -diff --git a/.forgejo/workflows/package.yaml b/.forgejo/workflows/package.yaml -new file mode 100644 -index 00000000..46a3954c ---- /dev/null -+++ b/.forgejo/workflows/package.yaml -@@ -0,0 +1,69 @@ -+name: Build Patched Release -+ -+on: -+ push: -+ branches: -+ - 'patches/*' -+ -+jobs: -+ build: -+ runs-on: docker -+ container: -+ image: ghcr.io/catthehacker/ubuntu:act-22.04 -+ -+ steps: -+ - name: Checkout -+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 -+ -+ - name: Set up JDK 17 -+ uses: https://github.com/actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0 -+ with: -+ java-version: "17" -+ distribution: "temurin" -+ -+ - uses: https://github.com/gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4.3.0 -+ with: -+ gradle-version: 8.12 -+ -+ - name: Run Gradle Command -+ run: ./gradlew clean build -+ env: -+ DOCKER_ENABLE_SECURITY: false -+ -+ - name: Get version number -+ id: versionNumber -+ run: echo "versionNumber=$(./gradlew printVersion --quiet | tail -1)" >> $GITHUB_OUTPUT -+ -+ - name: Login to Container Registry -+ uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 -+ with: -+ registry: git.spgrn.com -+ username: seang96 -+ password: ${{ secrets.TOKEN }} -+ -+ - name: Convert repository owner to lowercase -+ id: repoowner -+ run: echo "lowercase=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')" >> $GITHUB_OUTPUT -+ -+ - name: Generate tags fat -+ id: meta3 -+ uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1 -+ with: -+ images: | -+ git.spgrn.com/${{ steps.repoowner.outputs.lowercase }}/s-pdf -+ git.spgrn.com/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf -+ tags: | -+ type=raw,value=${{ steps.versionNumber.outputs.versionNumber }}-fat -+ type=raw,value=latest-fat -+ -+ - name: Build and push main Dockerfile fat -+ id: build-push-fat -+ uses: docker/build-push-action@v5 -+ with: -+ context: . -+ file: ./Dockerfile.fat -+ push: true -+ tags: ${{ steps.meta3.outputs.tags }} -+ labels: ${{ steps.meta3.outputs.labels }} -+ build-args: VERSION_TAG=${{ steps.versionNumber.outputs.versionNumber }} -+ platforms: linux/amd64 -\ No newline at end of file