#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere
TypeScript dockerhacktoberfestjavapdfpdf-converterpdf-editorpdf-manipulationpdf-mergerpdf-ocrpdf-toolspdf-web-appspdfmergerself-hosted
Harden actions secret handling (#7435)
Anthony Stirling929ded41a873
diff --git a/.github/workflows/PR-Auto-Deploy-V2.yml b/.github/workflows/PR-Auto-Deploy-V2.ymlindex 50be9fe4cf..1ae657fa76 100644--- a/.github/workflows/PR-Auto-Deploy-V2.yml+++ b/.github/workflows/PR-Auto-Deploy-V2.yml@@ -26,6 +26,10 @@ jobs:check-pr:if: (github.event_name == 'pull_request' && github.event.action != 'closed') || github.event_name == 'workflow_dispatch'runs-on: ubuntu-latest+ # Only reads the PR via pulls.get with the default GITHUB_TOKEN.+ permissions:+ contents: read+ pull-requests: readoutputs:should_deploy: ${{ steps.decide.outputs.should_deploy }}is_fork: ${{ steps.resolve.outputs.is_fork }}@@ -97,6 +101,7 @@ jobs:echo "allow_fork=${allow_fork:-false}" >> $GITHUB_OUTPUTdeploy-v2-pr:+ environment: pr-previewneeds: check-prruns-on: ubuntu-latestif: needs.check-pr.outputs.should_deploy == 'true' && (needs.check-pr.outputs.is_fork == 'false' || needs.check-pr.outputs.allow_fork == 'true')@@ -107,6 +112,7 @@ jobs:permissions:contents: readissues: write+ packages: writepull-requests: writeenv:# Single source of truth for whether this preview embeds the admin portal:@@ -125,20 +131,11 @@ jobs:repository: ${{ github.repository }}ref: main- - name: Setup GitHub App Bot- if: github.actor != 'dependabot[bot]'- id: setup-bot- uses: ./.github/actions/setup-bot- continue-on-error: true- with:- app-id: ${{ secrets.GH_APP_ID }}- private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}-- name: Add deployment started commentid: deployment-starteduses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0with:- github-token: ${{ steps.setup-bot.outputs.token }}+ github-token: ${{ github.token }}script: |const { owner, repo } = context.repo;const prNumber = ${{ needs.check-pr.outputs.pr_number }};@@ -180,7 +177,8 @@ jobs:with:repository: ${{ needs.check-pr.outputs.pr_repository }}ref: ${{ needs.check-pr.outputs.pr_ref }}- token: ${{ secrets.GITHUB_TOKEN }}+ # untrusted tree is built below - never leave credentials in .git/config+ persist-credentials: falsefetch-depth: 0 # Fetch full history for commit hash detection- name: Set up Docker Buildx@@ -192,11 +190,16 @@ jobs:VERSION=$(grep "^version =" build.gradle | awk -F'"' '{print $2}')echo "versionNumber=$VERSION" >> $GITHUB_OUTPUT- - name: Login to Docker Hub+ - name: Login to GitHub Container Registryuses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0with:- username: ${{ secrets.DOCKER_HUB_USERNAME }}- password: ${{ secrets.DOCKER_HUB_API }}+ registry: ghcr.io+ username: ${{ github.actor }}+ password: ${{ github.token }}++ - name: Convert repository owner to lowercase+ id: repoowner+ run: echo "lowercase=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')" >> $GITHUB_OUTPUT- name: Get commit hash for appid: commit-hash@@ -220,7 +223,7 @@ jobs:- name: Check if image existsid: check-imagerun: |- if docker manifest inspect ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-${{ steps.commit-hash.outputs.app_short }} >/dev/null 2>&1; then+ if docker manifest inspect ${IMAGE_BASE}:v2-${{ steps.commit-hash.outputs.app_short }} >/dev/null 2>&1; thenecho "exists=true" >> $GITHUB_OUTPUTecho "Image already exists, skipping build"else@@ -228,6 +231,8 @@ jobs:echo "Image needs to be built"fi+ env:+ IMAGE_BASE: ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf-test- name: Build and push V2 imageif: steps.check-image.outputs.exists == 'false'uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0@@ -237,7 +242,7 @@ jobs:push: truecache-from: type=gha,scope=stirling-pdf-latestcache-to: type=gha,mode=max,scope=stirling-pdf-latest- tags: ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-${{ steps.commit-hash.outputs.app_short }}+ tags: ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf-test:v2-${{ steps.commit-hash.outputs.app_short }}build-args: |VERSION_TAG=v2-alphaBUILD_PORTAL=${{ env.BUILD_PORTAL }}@@ -246,9 +251,11 @@ jobs:- name: Set up SSHrun: |mkdir -p ~/.ssh/- echo "${{ secrets.NEW_VPS_SSH_KEY }}" > ../private.key+ echo "${NEW_VPS_SSH_KEY}" > ../private.keysudo chmod 600 ../private.key+ env:+ NEW_VPS_SSH_KEY: ${{ secrets.NEW_VPS_SSH_KEY }}- name: Deploy V2 to VPSid: deployrun: |@@ -261,7 +268,7 @@ jobs:services:stirling-pdf-v2:container_name: stirling-pdf-v2-pr-${{ needs.check-pr.outputs.pr_number }}- image: ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-${{ steps.commit-hash.outputs.app_short }}+ image: ${IMAGE_BASE}:v2-${{ steps.commit-hash.outputs.app_short }}ports:- "${V2_PORT}:8080"volumes:@@ -273,8 +280,8 @@ jobs:DISABLE_ADDITIONAL_FEATURES: "false"STIRLING_BILLING_ACCOUNT_LINK_ENABLED: "true"SECURITY_ENABLELOGIN: "true"- SECURITY_INITIALLOGIN_USERNAME: "${{ secrets.TEST_LOGIN_USERNAME }}"- SECURITY_INITIALLOGIN_PASSWORD: "${{ secrets.TEST_LOGIN_PASSWORD }}"+ SECURITY_INITIALLOGIN_USERNAME: "${TEST_LOGIN_USERNAME}"+ SECURITY_INITIALLOGIN_PASSWORD: "${TEST_LOGIN_PASSWORD}"SYSTEM_DEFAULTLOCALE: en-USUI_APPNAME: "Stirling-PDF V2 PR#${{ needs.check-pr.outputs.pr_number }}"UI_HOMEDESCRIPTION: "V2 PR#${{ needs.check-pr.outputs.pr_number }} - Embedded Architecture"@@ -288,9 +295,9 @@ jobs:EOF# Deploy to VPS- scp -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null docker-compose.yml ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }}:/tmp/docker-compose-v2.yml+ scp -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null docker-compose.yml ${NEW_VPS_USERNAME}@${NEW_VPS_HOST}:/tmp/docker-compose-v2.yml- ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -T ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }} << ENDSSH+ ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -T ${NEW_VPS_USERNAME}@${NEW_VPS_HOST} << ENDSSH# Create V2 PR-specific directoriesmkdir -p /stirling/V2-PR-${{ needs.check-pr.outputs.pr_number }}/{data,config,logs,storage}@@ -315,6 +322,13 @@ jobs:# Set port for outputecho "v2_port=${V2_PORT}" >> $GITHUB_OUTPUT+ env:+ IMAGE_BASE: ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf-test+ TEST_LOGIN_USERNAME: ${{ secrets.TEST_LOGIN_USERNAME }}+ TEST_LOGIN_PASSWORD: ${{ secrets.TEST_LOGIN_PASSWORD }}+ NEW_VPS_USERNAME: ${{ secrets.NEW_VPS_USERNAME }}+ NEW_VPS_HOST: ${{ secrets.NEW_VPS_HOST }}+# ---- Storybook preview (only when this PR touches stories/.storybook) ----# Runs inside the same approved-contributor-gated deploy job, so it deploys# under the exact same access rules as the app preview.@@ -379,8 +393,9 @@ jobs:env:SB_URL: ${{ steps.storybook.outputs.url }}SB_FILES: ${{ steps.sb-changes.outputs.storybook_files }}+ NEW_VPS_HOST: ${{ secrets.NEW_VPS_HOST }}with:- github-token: ${{ steps.setup-bot.outputs.token }}+ github-token: ${{ github.token }}script: |const { owner, repo } = context.repo;const prNumber = ${{ needs.check-pr.outputs.pr_number }};@@ -401,7 +416,7 @@ jobs:}}- const deploymentUrl = `http://${{ secrets.NEW_VPS_HOST }}:${v2Port}`;+ const deploymentUrl = `http://${process.env.NEW_VPS_HOST}:${v2Port}`;// Only mention the portal when this image actually embeds it.// Use the direct IP URL - the SSL hostname isn't supported yet.@@ -447,6 +462,7 @@ jobs:});cleanup-v2-deployment:+ environment: pr-previewif: github.event.action == 'closed'runs-on: ubuntu-latestpermissions:@@ -463,19 +479,10 @@ jobs:- name: Checkout repositoryuses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2- - name: Setup GitHub App Bot- if: github.actor != 'dependabot[bot]'- id: setup-bot- uses: ./.github/actions/setup-bot- continue-on-error: true- with:- app-id: ${{ secrets.GH_APP_ID }}- private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}-- name: Clean up V2 deployment commentsuses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0with:- github-token: ${{ steps.setup-bot.outputs.token }}+ github-token: ${{ github.token }}script: |const { owner, repo } = context.repo;const prNumber = ${{ github.event.pull_request.number }};@@ -504,12 +511,14 @@ jobs:- name: Set up SSHrun: |mkdir -p ~/.ssh/- echo "${{ secrets.NEW_VPS_SSH_KEY }}" > ../private.key+ echo "${NEW_VPS_SSH_KEY}" > ../private.keysudo chmod 600 ../private.key+ env:+ NEW_VPS_SSH_KEY: ${{ secrets.NEW_VPS_SSH_KEY }}- name: Cleanup V2 deploymentrun: |- ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -T ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }} << 'ENDSSH'+ ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -T ${NEW_VPS_USERNAME}@${NEW_VPS_HOST} << 'ENDSSH'if [ -d "/stirling/V2-PR-${{ github.event.pull_request.number }}" ]; thenecho "Found V2 PR directory, proceeding with cleanup..."@@ -542,6 +551,9 @@ jobs:# Only remove PR-specific containers and directoriesENDSSH+ env:+ NEW_VPS_USERNAME: ${{ secrets.NEW_VPS_USERNAME }}+ NEW_VPS_HOST: ${{ secrets.NEW_VPS_HOST }}- name: Cleanup temporary filesif: always()run: |diff --git a/.github/workflows/PR-Demo-Comment-with-react.yml b/.github/workflows/PR-Demo-Comment-with-react.ymlindex c804489836..8e0e66032e 100644--- a/.github/workflows/PR-Demo-Comment-with-react.yml+++ b/.github/workflows/PR-Demo-Comment-with-react.yml@@ -37,7 +37,8 @@ jobs:check-comment:runs-on: ubuntu-latestpermissions:- issues: write+ contents: read # actions/checkout+ issues: write # add reaction to the triggering issue commentif: |vars.CI_PROFILE != 'lite' && (github.event_name == 'workflow_dispatch' ||@@ -76,15 +77,6 @@ jobs:- name: Checkout PRuses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2- - name: Setup GitHub App Bot- if: github.actor != 'dependabot[bot]'- id: setup-bot- uses: ./.github/actions/setup-bot- continue-on-error: true- with:- app-id: ${{ secrets.GH_APP_ID }}- private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}-- name: Get PR dataid: get-pruses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0@@ -155,7 +147,7 @@ jobs:id: add-eyes-reactionuses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0with:- github-token: ${{ steps.setup-bot.outputs.token }}+ github-token: ${{ github.token }}script: |console.log(`Adding eyes reaction to comment ID: ${context.payload.comment.id}`);try {@@ -174,11 +166,14 @@ jobs:}deploy-pr:+ environment: pr-previewneeds: check-commentruns-on: ubuntu-latestpermissions:- issues: write+ contents: read # actions/checkout, incl. the PR merge ref+ issues: write # reactions, 'pr-deployed' label, deployment URL commentpull-requests: write+ packages: write # push PR image to ghcr.iosteps:- name: Harden Runner@@ -189,20 +184,12 @@ jobs:- name: Checkout PRuses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2- - name: Setup GitHub App Bot- if: github.actor != 'dependabot[bot]'- id: setup-bot- uses: ./.github/actions/setup-bot- continue-on-error: true- with:- app-id: ${{ secrets.GH_APP_ID }}- private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}-- name: Checkout PRuses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2with:ref: refs/pull/${{ needs.check-comment.outputs.pr_number }}/merge- token: ${{ steps.setup-bot.outputs.token }}+ # untrusted tree gets built below - never leave credentials in .git/config+ persist-credentials: false- name: Set up JDK 25uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0@@ -240,11 +227,16 @@ jobs:- name: Set up Docker Buildxuses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0- - name: Login to Docker Hub+ - name: Login to GitHub Container Registryuses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0with:- username: ${{ secrets.DOCKER_HUB_USERNAME }}- password: ${{ secrets.DOCKER_HUB_API }}+ registry: ghcr.io+ username: ${{ github.actor }}+ password: ${{ github.token }}++ - name: Convert repository owner to lowercase+ id: repoowner+ run: echo "lowercase=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')" >> $GITHUB_OUTPUT- name: Build and push PR-specific imageuses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0@@ -254,7 +246,7 @@ jobs:push: truecache-from: type=gha,scope=stirling-pdf-latestcache-to: type=gha,mode=max,scope=stirling-pdf-latest- tags: ${{ secrets.DOCKER_HUB_USERNAME }}/test:pr-${{ needs.check-comment.outputs.pr_number }}+ tags: ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf-test:pr-${{ needs.check-comment.outputs.pr_number }}build-args: |VERSION_TAG=alphaPROTOTYPES_BUILD=${{ needs.check-comment.outputs.enable_prototypes }}@@ -269,15 +261,17 @@ jobs:push: truecache-from: type=gha,scope=stirling-pdf-enginecache-to: type=gha,mode=max,scope=stirling-pdf-engine- tags: ${{ secrets.DOCKER_HUB_USERNAME }}/test:engine-pr-${{ needs.check-comment.outputs.pr_number }}+ tags: ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf-test:engine-pr-${{ needs.check-comment.outputs.pr_number }}platforms: linux/amd64- name: Set up SSHrun: |mkdir -p ~/.ssh/- echo "${{ secrets.NEW_VPS_SSH_KEY }}" > ../private.key+ echo "${NEW_VPS_SSH_KEY}" > ../private.keysudo chmod 600 ../private.key+ env:+ NEW_VPS_SSH_KEY: ${{ secrets.NEW_VPS_SSH_KEY }}- name: Deploy to VPSid: deployrun: |@@ -295,11 +289,11 @@ jobs:# Set pro/enterprise settings (enterprise implies pro)if [ "${{ needs.check-comment.outputs.enable_enterprise }}" == "true" ]; thenPREMIUM_ENABLED="true"- PREMIUM_KEY="${{ secrets.ENTERPRISE_KEY }}"+ PREMIUM_KEY="${ENTERPRISE_KEY}"PREMIUM_PROFEATURES_AUDIT_ENABLED="true"elif [ "${{ needs.check-comment.outputs.enable_pro }}" == "true" ]; thenPREMIUM_ENABLED="true"- PREMIUM_KEY="${{ secrets.PREMIUM_KEY }}"+ PREMIUM_KEY="${PRO_KEY}"PREMIUM_PROFEATURES_AUDIT_ENABLED="true"elsePREMIUM_ENABLED="false"@@ -309,7 +303,6 @@ jobs:ENABLE_PROTOTYPES="${{ needs.check-comment.outputs.enable_prototypes }}"PR_NUMBER="${{ needs.check-comment.outputs.pr_number }}"- DOCKER_USER="${{ secrets.DOCKER_HUB_USERNAME }}"# Build engine env vars for backend (only set when prototypes enabled)if [ "$ENABLE_PROTOTYPES" == "true" ]; then@@ -319,9 +312,9 @@ jobs:ENGINE_SERVICE="stirling-pdf-engine:container_name: stirling-pdf-engine-pr-${PR_NUMBER}- image: ${DOCKER_USER}/test:engine-pr-${PR_NUMBER}+ image: ${IMAGE_BASE}:engine-pr-${PR_NUMBER}environment:- ANTHROPIC_API_KEY: \"${{ secrets.ANTHROPIC_API_KEY }}\"+ ANTHROPIC_API_KEY: \"${ANTHROPIC_API_KEY}\"networks:- pr-networkrestart: on-failure:5"@@ -344,7 +337,7 @@ jobs:services:stirling-pdf:container_name: stirling-pdf-pr-${PR_NUMBER}- image: ${DOCKER_USER}/test:pr-${PR_NUMBER}+ image: ${IMAGE_BASE}:pr-${PR_NUMBER}ports:- "${PR_NUMBER}:8080"volumes:@@ -368,9 +361,9 @@ jobs:EOF# Then copy the file and execute commands- scp -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null docker-compose.yml ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }}:/tmp/docker-compose.yml+ scp -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null docker-compose.yml ${NEW_VPS_USERNAME}@${NEW_VPS_HOST}:/tmp/docker-compose.yml- ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -T ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }} << ENDSSH+ ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -T ${NEW_VPS_USERNAME}@${NEW_VPS_HOST} << ENDSSH# Create PR-specific directoriesmkdir -p /stirling/PR-${PR_NUMBER}/{data,config,logs}@@ -386,11 +379,19 @@ jobs:# Set output for use in PR commentecho "security_status=${SECURITY_STATUS}" >> $GITHUB_ENV+ env:+ ENTERPRISE_KEY: ${{ secrets.ENTERPRISE_KEY }}+ # named PRO_KEY, not PREMIUM_KEY, so the shell var it feeds is not self-referential+ PRO_KEY: ${{ secrets.PREMIUM_KEY }}+ ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}+ IMAGE_BASE: ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf-test+ NEW_VPS_USERNAME: ${{ secrets.NEW_VPS_USERNAME }}+ NEW_VPS_HOST: ${{ secrets.NEW_VPS_HOST }}- name: Add success reaction to commentif: success() && github.event_name == 'issue_comment'uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0with:- github-token: ${{ steps.setup-bot.outputs.token }}+ github-token: ${{ github.token }}script: |console.log(`Adding rocket reaction to comment ID: ${{ needs.check-comment.outputs.comment_id }}`);try {@@ -425,7 +426,7 @@ jobs:if: failure() && github.event_name == 'issue_comment'uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0with:- github-token: ${{ steps.setup-bot.outputs.token }}+ github-token: ${{ github.token }}script: |console.log(`Adding -1 reaction to comment ID: ${{ needs.check-comment.outputs.comment_id }}`);try {@@ -444,15 +445,17 @@ jobs:- name: Post deployment URL to PRif: success()uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0+ env:+ NEW_VPS_HOST: ${{ secrets.NEW_VPS_HOST }}with:- github-token: ${{ steps.setup-bot.outputs.token }}+ github-token: ${{ github.token }}script: |const { GITHUB_REPOSITORY } = process.env;const [repoOwner, repoName] = GITHUB_REPOSITORY.split('/');const prNumber = ${{ needs.check-comment.outputs.pr_number }};const securityStatus = process.env.security_status || "Security Disabled";- const deploymentUrl = `http://${{ secrets.NEW_VPS_HOST }}:${prNumber}`;+ const deploymentUrl = `http://${process.env.NEW_VPS_HOST}:${prNumber}`;const commentBody = `## π PR Test Deployment\n\n` +`Your PR has been deployed for testing!\n\n` +`π **Test URL:** [${deploymentUrl}](${deploymentUrl})\n` +@@ -477,6 +480,9 @@ jobs:handle-label-commands:if: ${{ github.event.issue.pull_request != null }}runs-on: ubuntu-latest+ permissions:+ contents: read # actions/checkout, reads repo_devs.json and labels.yml+ issues: write # add/remove labels, delete the command commentsteps:- name: Harden Runneruses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0@@ -486,17 +492,10 @@ jobs:- name: Check out the repositoryuses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2- - name: Setup GitHub App Bot- id: setup-bot- uses: ./.github/actions/setup-bot- with:- app-id: ${{ secrets.GH_APP_ID }}- private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}-- name: Apply label commandsuses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0with:- github-token: ${{ steps.setup-bot.outputs.token }}+ github-token: ${{ github.token }}script: |const fs = require('fs');const path = require('path');diff --git a/.github/workflows/PR-Demo-cleanup.yml b/.github/workflows/PR-Demo-cleanup.ymlindex 146f5c7f78..7b4ee8b3a3 100644--- a/.github/workflows/PR-Demo-cleanup.yml+++ b/.github/workflows/PR-Demo-cleanup.yml@@ -13,11 +13,13 @@ env:jobs:cleanup:+ environment: pr-previewif: github.event.action == 'closed'runs-on: ubuntu-latestpermissions:+ contents: read # actions/checkoutpull-requests: write- issues: write+ issues: write # list/remove labels, list/delete commentssteps:- name: Harden Runner@@ -28,20 +30,11 @@ jobs:- name: Checkout PRuses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2- - name: Setup GitHub App Bot- if: github.actor != 'dependabot[bot]'- id: setup-bot- uses: ./.github/actions/setup-bot- continue-on-error: true- with:- app-id: ${{ secrets.GH_APP_ID }}- private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}-- name: Remove 'pr-deployed' label if presentid: remove-label-commentuses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0with:- github-token: ${{ steps.setup-bot.outputs.token }}+ github-token: ${{ github.token }}script: |const prNumber = ${{ github.event.pull_request.number }};const owner = context.repo.owner;@@ -100,14 +93,22 @@ jobs:if: steps.remove-label-comment.outputs.present == 'true'run: |mkdir -p ~/.ssh/- echo "${{ secrets.NEW_VPS_SSH_KEY }}" > ../private.key+ echo "${NEW_VPS_SSH_KEY}" > ../private.keysudo chmod 600 ../private.key+ env:+ NEW_VPS_SSH_KEY: ${{ secrets.NEW_VPS_SSH_KEY }}++ - name: Convert repository owner to lowercase+ id: repoowner+ run: echo "lowercase=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')" >> $GITHUB_OUTPUT- name: Cleanup PR deploymentif: steps.remove-label-comment.outputs.present == 'true'id: cleanup+ # ENDSSH heredoc is quoted, so its body is sent literally: secrets inside it+ # must stay as GitHub expressions, a shell var would be empty on the remote host.run: |- ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -T ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }} << 'ENDSSH'+ ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -T ${NEW_VPS_USERNAME}@${NEW_VPS_HOST} << 'ENDSSH'if [ -d "/stirling/PR-${{ github.event.pull_request.number }}" ]; thenecho "Found PR directory, proceeding with cleanup..."@@ -122,8 +123,8 @@ jobs:rm -rf /stirling/PR-${{ github.event.pull_request.number }}# Remove the Docker images- docker rmi --no-prune ${{ secrets.DOCKER_HUB_USERNAME }}/test:pr-${{ github.event.pull_request.number }} || true- docker rmi --no-prune ${{ secrets.DOCKER_HUB_USERNAME }}/test:engine-pr-${{ github.event.pull_request.number }} || true+ docker rmi --no-prune ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf-test:pr-${{ github.event.pull_request.number }} || true+ docker rmi --no-prune ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf-test:engine-pr-${{ github.event.pull_request.number }} || trueecho "PERFORMED_CLEANUP"else@@ -131,6 +132,9 @@ jobs:echo "NO_CLEANUP_NEEDED"fiENDSSH+ env:+ NEW_VPS_USERNAME: ${{ secrets.NEW_VPS_USERNAME }}+ NEW_VPS_HOST: ${{ secrets.NEW_VPS_HOST }}- name: Cleanup temporary filesif: always()diff --git a/.github/workflows/ai_pr_title_review.yml b/.github/workflows/ai_pr_title_review.ymlindex 563e94c9b3..9922177b4b 100644--- a/.github/workflows/ai_pr_title_review.yml+++ b/.github/workflows/ai_pr_title_review.yml@@ -10,10 +10,12 @@ permissions: # required for secure-repo hardeningjobs:ai-title-review:+ # GITHUB_TOKEN obeys this block, so it must cover every API call made below.permissions:- contents: read- pull-requests: write- models: read+ contents: read # actions/checkout, git fetch/diff+ issues: write # issues.listComments / createComment / updateComment on the PR+ pull-requests: write # same endpoints when the target is a pull request+ models: read # actions/ai-inferenceruns-on: ubuntu-latest@@ -30,15 +32,6 @@ jobs:- name: Configure Git to suppress detached HEAD warningrun: git config --global advice.detachedHead false- - name: Setup GitHub App Bot- if: github.actor != 'dependabot[bot]'- id: setup-bot- uses: ./.github/actions/setup-bot- continue-on-error: true- with:- app-id: ${{ secrets.GH_APP_ID }}- private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}-- name: Check if actor is repo developerid: actorrun: |@@ -161,7 +154,7 @@ jobs:uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0continue-on-error: truewith:- github-token: ${{ steps.setup-bot.outputs.token }}+ github-token: ${{ github.token }}script: |const fs = require('fs');const body = fs.readFileSync('/tmp/ai-title-comment.md', 'utf8');@@ -172,7 +165,7 @@ jobs:const ratingMatch = body.match(/\*\*PR-Title Rating\*\*: (\d+)\/10/);const rating = ratingMatch ? parseInt(ratingMatch[1], 10) : null;- const expectedActor = "${{ steps.setup-bot.outputs.app-slug }}[bot]";+ const expectedActor = "github-actions[bot]";const comments = await github.rest.issues.listComments({ owner, repo, issue_number });const existing = comments.data.find(c =>diff --git a/.github/workflows/aur-publish.yml b/.github/workflows/aur-publish.ymlindex f5af23da07..f1ca2be8ca 100644--- a/.github/workflows/aur-publish.yml+++ b/.github/workflows/aur-publish.yml@@ -66,6 +66,7 @@ jobs:echo "jar_sha256=$JAR_SHA" >> "$GITHUB_OUTPUT"publish-aur:+ environment: package-publishneeds: get-release-inforuns-on: ubuntu-lateststeps:diff --git a/.github/workflows/auto-labelerV2.yml b/.github/workflows/auto-labelerV2.ymlindex 6039c0e7df..bcbd0fcba5 100644--- a/.github/workflows/auto-labelerV2.yml+++ b/.github/workflows/auto-labelerV2.yml@@ -13,7 +13,9 @@ jobs:labeler:runs-on: ubuntu-latestpermissions:- pull-requests: write+ contents: read # checkout + labeler fetching its config from the repo+ pull-requests: write # read changed files, apply labels to the PR+ issues: write # labels are applied through the issues APIsteps:- name: Harden Runneruses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0@@ -22,17 +24,10 @@ jobs:- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2- - name: Setup GitHub App Bot- id: setup-bot- uses: ./.github/actions/setup-bot- with:- app-id: ${{ secrets.GH_APP_ID }}- private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}-- uses: srvaroa/labeler@bf262763a8a8e191f5847873aecc0f29df84f957 # v1.14.0with:config_path: .github/labeler-config-srvaroa.ymluse_local_config: falsefail_on_error: trueenv:- GITHUB_TOKEN: "${{ steps.setup-bot.outputs.token }}"+ GITHUB_TOKEN: "${{ github.token }}"diff --git a/.github/workflows/check_toml.yml b/.github/workflows/check_toml.ymlindex d134c80a9b..eff416c379 100644--- a/.github/workflows/check_toml.yml+++ b/.github/workflows/check_toml.yml@@ -23,6 +23,7 @@ jobs:if: github.event_name == 'pull_request_target'runs-on: ubuntu-latestpermissions:+ contents: read # Checkout, and read translation files via the contents APIissues: write # Allow posting comments on issues/PRspull-requests: write # Allow writing to pull requestssteps:@@ -34,18 +35,11 @@ jobs:- name: Checkout main branch firstuses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2- - name: Setup GitHub App Bot- id: setup-bot- uses: ./.github/actions/setup-bot- with:- app-id: ${{ secrets.GH_APP_ID }}- private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}-- name: Get PR dataid: get-pr-datauses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0with:- github-token: ${{ steps.setup-bot.outputs.token }}+ github-token: ${{ github.token }}script: |const prNumber = context.payload.pull_request.number;const repoOwner = context.payload.repository.owner.login;@@ -66,17 +60,18 @@ jobs:- name: Fetch PR changed filesid: fetch-pr-changesenv:- GH_TOKEN: ${{ steps.setup-bot.outputs.token }}+ GH_TOKEN: ${{ github.token }}+ PR_NUMBER: ${{ steps.get-pr-data.outputs.pr_number }}run: |echo "Fetching PR changed files..."echo "Getting list of changed files from PR..."# Check if PR number exists- if [ -z "${{ steps.get-pr-data.outputs.pr_number }}" ]; then+ if [ -z "${PR_NUMBER}" ]; thenecho "Error: PR number is empty"exit 1fi# Get changed files and filter for TOML translation files- gh pr view ${{ steps.get-pr-data.outputs.pr_number }} --json files -q ".files[].path" | grep -E '^frontend/editor/public/locales/[a-zA-Z-]+/translation\.toml$' > changed_files.txt || echo "No matching TOML files found in PR"+ gh pr view "${PR_NUMBER}" --json files -q ".files[].path" | grep -E '^frontend/editor/public/locales/[a-zA-Z-]+/translation\.toml$' > changed_files.txt || echo "No matching TOML files found in PR"# Check if any files were foundif [ ! -s changed_files.txt ]; thenecho "No TOML translation files changed in this PR"@@ -88,32 +83,36 @@ jobs:- name: Determine reference fileid: determine-fileuses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0+ env:+ # Untrusted, fork-controlled values are passed via env, never interpolated into the script+ PR_NUMBER: ${{ steps.get-pr-data.outputs.pr_number }}+ REPO_OWNER: ${{ steps.get-pr-data.outputs.repo_owner }}+ REPO_NAME: ${{ steps.get-pr-data.outputs.repo_name }}+ PR_REPO_OWNER: ${{ github.event.pull_request.head.repo.owner.login }}+ PR_REPO_NAME: ${{ github.event.pull_request.head.repo.name }}+ PR_BRANCH: ${{ steps.get-pr-data.outputs.branch }}with:- github-token: ${{ steps.setup-bot.outputs.token }}+ github-token: ${{ github.token }}script: |const fs = require("fs");const path = require("path");- const prNumber = ${{ steps.get-pr-data.outputs.pr_number }};- const repoOwner = "${{ steps.get-pr-data.outputs.repo_owner }}";- const repoName = "${{ steps.get-pr-data.outputs.repo_name }}";-- const prRepoOwner = "${{ github.event.pull_request.head.repo.owner.login }}";- const prRepoName = "${{ github.event.pull_request.head.repo.name }}";- const branch = "${{ steps.get-pr-data.outputs.branch }}";-- console.log(`Determining reference file for PR #${prNumber}`);-- // Validate inputs+ // Validate inputs before any useconst validateInput = (input, regex, name) => {- if (!regex.test(input)) {+ if (typeof input !== "string" || !regex.test(input)) {throw new Error(`Invalid ${name}: ${input}`);}+ return input;};- validateInput(repoOwner, /^[a-zA-Z0-9_-]+$/, "repository owner");- validateInput(repoName, /^[a-zA-Z0-9._-]+$/, "repository name");- validateInput(branch, /^[a-zA-Z0-9._/-]+$/, "branch name");+ const repoOwner = validateInput(process.env.REPO_OWNER, /^[a-zA-Z0-9_-]+$/, "repository owner");+ const repoName = validateInput(process.env.REPO_NAME, /^[a-zA-Z0-9._-]+$/, "repository name");+ const prRepoOwner = validateInput(process.env.PR_REPO_OWNER, /^[a-zA-Z0-9_-]+$/, "PR repository owner");+ const prRepoName = validateInput(process.env.PR_REPO_NAME, /^[a-zA-Z0-9._-]+$/, "PR repository name");+ const branch = validateInput(process.env.PR_BRANCH, /^[a-zA-Z0-9._/-]+$/, "branch name");+ const prNumber = Number(validateInput(process.env.PR_NUMBER, /^[0-9]+$/, "PR number"));++ console.log(`Determining reference file for PR #${prNumber}`);// Get the list of changed files in the PRconst { data: files } = await github.rest.pulls.listFiles({@@ -209,10 +208,12 @@ jobs:- name: Run Python script to check filesid: run-check+ env:+ PR_ACTOR: ${{ github.event.pull_request.user.login }}run: |echo "Running Python script to check TOML files..."uv run --project engine --locked --group tools python .github/scripts/check_language_toml.py \- --actor ${{ github.event.pull_request.user.login }} \+ --actor "${PR_ACTOR}" \--reference-file "${REFERENCE_FILE}" \--branch "pr-branch" \--files "${FILES_LIST[@]}" > result.txt@@ -245,7 +246,7 @@ jobs:if: env.SCRIPT_OUTPUT != ''uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0with:- github-token: ${{ steps.setup-bot.outputs.token }}+ github-token: ${{ github.token }}script: |const { GITHUB_REPOSITORY, SCRIPT_OUTPUT } = process.env;const [repoOwner, repoName] = GITHUB_REPOSITORY.split('/');@@ -261,7 +262,7 @@ jobs:const comment = comments.data.find(c => c.body.includes("## π TOML Translation Verification Summary"));// Only update or create comments by the action user- const expectedActor = "${{ steps.setup-bot.outputs.app-slug }}[bot]";+ const expectedActor = "github-actions[bot]";if (comment && comment.user.login === expectedActor) {// Update existing commentdiff --git a/.github/workflows/deploy-on-v2-commit.yml b/.github/workflows/deploy-on-v2-commit.ymlindex c98ec8641c..21d12044f5 100644--- a/.github/workflows/deploy-on-v2-commit.yml+++ b/.github/workflows/deploy-on-v2-commit.yml@@ -11,7 +11,11 @@ permissions:jobs:deploy-v2-on-push:+ environment: pr-previewruns-on: ubuntu-latest+ permissions:+ contents: read+ packages: writeconcurrency:group: deploy-v2-push-V2cancel-in-progress: true@@ -62,10 +66,21 @@ jobs:echo "backend_short=${BACKEND_HASH:0:8}" >> $GITHUB_OUTPUTfi+ - name: Convert repository owner to lowercase+ id: repoowner+ run: echo "lowercase=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')" >> $GITHUB_OUTPUT++ - name: Login to GitHub Container Registry+ uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0+ with:+ registry: ghcr.io+ username: ${{ github.actor }}+ password: ${{ github.token }}+- name: Check if frontend image existsid: check-frontendrun: |- if docker manifest inspect ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-frontend-${{ steps.commit-hashes.outputs.frontend_short }} >/dev/null 2>&1; then+ if docker manifest inspect ${IMAGE_BASE}:v2-frontend-${{ steps.commit-hashes.outputs.frontend_short }} >/dev/null 2>&1; thenecho "exists=true" >> $GITHUB_OUTPUTecho "Frontend image already exists, skipping build"else@@ -73,10 +88,12 @@ jobs:echo "Frontend image needs to be built"fi+ env:+ IMAGE_BASE: ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf-test- name: Check if backend image existsid: check-backendrun: |- if docker manifest inspect ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-backend-${{ steps.commit-hashes.outputs.backend_short }} >/dev/null 2>&1; then+ if docker manifest inspect ${IMAGE_BASE}:v2-backend-${{ steps.commit-hashes.outputs.backend_short }} >/dev/null 2>&1; thenecho "exists=true" >> $GITHUB_OUTPUTecho "Backend image already exists, skipping build"else@@ -84,11 +101,8 @@ jobs:echo "Backend image needs to be built"fi- - name: Login to Docker Hub- uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0- with:- username: ${{ secrets.DOCKER_HUB_USERNAME }}- password: ${{ secrets.DOCKER_HUB_API }}+ env:+ IMAGE_BASE: ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf-test- name: Build and push frontend imageif: steps.check-frontend.outputs.exists == 'false'@@ -100,8 +114,8 @@ jobs:cache-from: type=gha,scope=stirling-v2-frontendcache-to: type=gha,mode=max,scope=stirling-v2-frontendtags: |- ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-frontend-${{ steps.commit-hashes.outputs.frontend_short }}- ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-frontend-latest+ ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf-test:v2-frontend-${{ steps.commit-hashes.outputs.frontend_short }}+ ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf-test:v2-frontend-latestbuild-args: VERSION_TAG=v2-alphaplatforms: linux/amd64@@ -115,17 +129,19 @@ jobs:cache-from: type=gha,scope=stirling-v2-backendcache-to: type=gha,mode=max,scope=stirling-v2-backendtags: |- ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-backend-${{ steps.commit-hashes.outputs.backend_short }}- ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-backend-latest+ ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf-test:v2-backend-${{ steps.commit-hashes.outputs.backend_short }}+ ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf-test:v2-backend-latestbuild-args: VERSION_TAG=v2-alphaplatforms: linux/amd64- name: Set up SSHrun: |mkdir -p ~/.ssh/- echo "${{ secrets.NEW_VPS_SSH_KEY }}" > ../private.key+ echo "${NEW_VPS_SSH_KEY}" > ../private.keychmod 600 ../private.key+ env:+ NEW_VPS_SSH_KEY: ${{ secrets.NEW_VPS_SSH_KEY }}- name: Deploy to VPS on port 3000run: |export UNIQUE_NAME=docker-compose-v2-$GITHUB_RUN_ID.yml@@ -135,7 +151,7 @@ jobs:services:backend:container_name: stirling-v2-backend- image: ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-backend-${{ steps.commit-hashes.outputs.backend_short }}+ image: ${IMAGE_BASE}:v2-backend-${{ steps.commit-hashes.outputs.backend_short }}ports:- "13000:8080"volumes:@@ -158,21 +174,21 @@ jobs:frontend:container_name: stirling-v2-frontend- image: ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-frontend-${{ steps.commit-hashes.outputs.frontend_short }}+ image: ${IMAGE_BASE}:v2-frontend-${{ steps.commit-hashes.outputs.frontend_short }}ports:- "3000:80"environment:- VITE_API_BASE_URL: "http://${{ secrets.NEW_VPS_HOST }}:13000"+ VITE_API_BASE_URL: "http://${NEW_VPS_HOST}:13000"depends_on:- backendrestart: on-failure:5EOF# Copy to remote with unique name- scp -i ../private.key -o StrictHostKeyChecking=no $UNIQUE_NAME ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }}:/tmp/$UNIQUE_NAME+ scp -i ../private.key -o StrictHostKeyChecking=no $UNIQUE_NAME ${NEW_VPS_USERNAME}@${NEW_VPS_HOST}:/tmp/$UNIQUE_NAME# SSH and rename/move atomically to avoid interference- ssh -i ../private.key -o StrictHostKeyChecking=no ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }} << ENDSSH+ ssh -i ../private.key -o StrictHostKeyChecking=no ${NEW_VPS_USERNAME}@${NEW_VPS_HOST} << ENDSSHmkdir -p /stirling/V2/{data,config,logs}mv /tmp/$UNIQUE_NAME /stirling/V2/docker-compose.ymlcd /stirling/V2@@ -183,6 +199,10 @@ jobs:docker image prune -af --filter "until=336h" --filter "label!=keep=true" || trueENDSSH+ env:+ IMAGE_BASE: ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf-test+ NEW_VPS_HOST: ${{ secrets.NEW_VPS_HOST }}+ NEW_VPS_USERNAME: ${{ secrets.NEW_VPS_USERNAME }}- name: Cleanup temporary filesif: always()run: |diff --git a/.github/workflows/multiOSReleases.yml b/.github/workflows/multiOSReleases.ymlindex f02e6c612c..c712467e7b 100644--- a/.github/workflows/multiOSReleases.yml+++ b/.github/workflows/multiOSReleases.yml@@ -93,7 +93,7 @@ jobs:ALL="$WINDOWS,$WINDOWS_ARM64,$MACOS,$LINUX"if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then- case "${{ github.event.inputs.platform }}" in+ case "${INPUT_PLATFORM}" in"windows")echo "matrix={\"include\":[$WINDOWS,$WINDOWS_ARM64]}" >> $GITHUB_OUTPUT;;@@ -115,6 +115,8 @@ jobs:echo "matrix={\"include\":[$ALL]}" >> $GITHUB_OUTPUTfi+ env:+ INPUT_PLATFORM: ${{ github.event.inputs.platform }}build-jars:needs: determine-matrixruns-on: ubuntu-latest@@ -194,6 +196,7 @@ jobs:retention-days: 1build:+ environment: release-signingneeds: determine-matrixstrategy:fail-fast: false@@ -308,16 +311,16 @@ jobs:Write-Host "Setting up DigiCert KeyLocker environment..."# Decode client certificate- $certBytes = [Convert]::FromBase64String("${{ secrets.SM_CLIENT_CERT_FILE_B64 }}")+ $certBytes = [Convert]::FromBase64String("$env:SM_CLIENT_CERT_FILE_B64")$certPath = "D:\Certificate_pkcs12.p12"[IO.File]::WriteAllBytes($certPath, $certBytes)# Set environment variablesecho "SM_CLIENT_CERT_FILE=D:\Certificate_pkcs12.p12" >> $env:GITHUB_ENV- echo "SM_HOST=${{ secrets.SM_HOST }}" >> $env:GITHUB_ENV- echo "SM_API_KEY=${{ secrets.SM_API_KEY }}" >> $env:GITHUB_ENV- echo "SM_CLIENT_CERT_PASSWORD=${{ secrets.SM_CLIENT_CERT_PASSWORD }}" >> $env:GITHUB_ENV- echo "SM_KEYPAIR_ALIAS=${{ secrets.SM_KEYPAIR_ALIAS }}" >> $env:GITHUB_ENV+ echo "SM_HOST=$env:SM_HOST" >> $env:GITHUB_ENV+ echo "SM_API_KEY=$env:SM_API_KEY" >> $env:GITHUB_ENV+ echo "SM_CLIENT_CERT_PASSWORD=$env:SM_CLIENT_CERT_PASSWORD" >> $env:GITHUB_ENV+ echo "SM_KEYPAIR_ALIAS=$env:SM_KEYPAIR_ALIAS" >> $env:GITHUB_ENV# Get PKCS11 config path from DigiCert action$pkcs11Config = $env:PKCS11_CONFIG@@ -335,6 +338,12 @@ jobs:}}+ env:+ SM_CLIENT_CERT_FILE_B64: ${{ secrets.SM_CLIENT_CERT_FILE_B64 }}+ SM_HOST: ${{ secrets.SM_HOST }}+ SM_API_KEY: ${{ secrets.SM_API_KEY }}+ SM_CLIENT_CERT_PASSWORD: ${{ secrets.SM_CLIENT_CERT_PASSWORD }}+ SM_KEYPAIR_ALIAS: ${{ secrets.SM_KEYPAIR_ALIAS }}# Traditional PFX Certificate Import (fallback if KeyLocker not configured)- name: Import Windows Code Signing Certificateif: ${{ startsWith(matrix.platform, 'windows') && env.SM_API_KEY == '' && (github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.sign != 'false') || github.ref == 'refs/heads/V2-master') }}diff --git a/.github/workflows/package-managers.yml b/.github/workflows/package-managers.ymlindex e88c5e400e..751b3c1877 100644--- a/.github/workflows/package-managers.yml+++ b/.github/workflows/package-managers.yml@@ -73,6 +73,7 @@ jobs:echo "jar_sha256=$JAR_SHA" >> "$GITHUB_OUTPUT"update-homebrew-and-scoop:+ environment: package-publishneeds: get-release-inforuns-on: ubuntu-latestpermissions:diff --git a/.github/workflows/pr-conflict-labeler.yml b/.github/workflows/pr-conflict-labeler.ymlindex a44d4f7b28..362421d0f8 100644--- a/.github/workflows/pr-conflict-labeler.yml+++ b/.github/workflows/pr-conflict-labeler.yml@@ -27,9 +27,9 @@ jobs:name: Label conflicted PRsruns-on: ubuntu-latestpermissions:- contents: read- issues: write- pull-requests: read+ contents: read # actions/checkout+ issues: write # get/create the repo-level conflict label+ pull-requests: write # pulls.get/list plus add/remove the label on PRssteps:- name: Harden Runneruses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0@@ -39,17 +39,10 @@ jobs:- name: Check out the repositoryuses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2- - name: Set up stirling-bot token- id: setup-bot- uses: ./.github/actions/setup-bot- with:- app-id: ${{ secrets.GH_APP_ID }}- private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}-- name: Apply conflict labeluses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0with:- github-token: ${{ steps.setup-bot.outputs.token }}+ github-token: ${{ github.token }}script: |const conflictLabel = process.env.CONFLICT_LABEL;const owner = context.repo.owner;diff --git a/.github/workflows/push-docker-base.yml b/.github/workflows/push-docker-base.ymlindex 167b71531e..f7dd1bcab4 100644--- a/.github/workflows/push-docker-base.yml+++ b/.github/workflows/push-docker-base.yml@@ -32,9 +32,11 @@ jobs:- name: Set versionid: version+ env:+ INPUT_VERSION: ${{ github.event.inputs.version }}run: |if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then- VERSION="${{ github.event.inputs.version }}"+ VERSION="${INPUT_VERSION}"elif [ "${{ github.ref_name }}" == "accessIssueFix" ]; thenVERSION="1.0.3"elsediff --git a/.github/workflows/push-docker.yml b/.github/workflows/push-docker.ymlindex 906884aaab..c9caf1b2f2 100644--- a/.github/workflows/push-docker.yml+++ b/.github/workflows/push-docker.yml@@ -23,7 +23,6 @@ on:- master- main- V2-master- - testMain# cancel in-progress jobs if a new job is triggered# This is useful to avoid running multiple builds for the same branch if a new commit is pushed@@ -42,6 +41,7 @@ permissions:jobs:push:+ environment: docker-publishif: ${{ vars.CI_PROFILE != 'lite' }}runs-on: ubuntu-24.04-8corepermissions:diff --git a/.github/workflows/rollback-latest.yml b/.github/workflows/rollback-latest.ymlindex 27141eff31..442a6f499e 100644--- a/.github/workflows/rollback-latest.yml+++ b/.github/workflows/rollback-latest.yml@@ -13,6 +13,7 @@ permissions:jobs:rollback:+ environment: docker-publishruns-on: ubuntu-latestpermissions:packages: writediff --git a/.github/workflows/sync-portal-docs.yml b/.github/workflows/sync-portal-docs.ymlindex 0b27858d5f..5ff4f465c7 100644--- a/.github/workflows/sync-portal-docs.yml+++ b/.github/workflows/sync-portal-docs.yml@@ -24,6 +24,7 @@ permissions:jobs:sync:+ environment: bot-identityname: Sync docs manifestruns-on: ubuntu-latesttimeout-minutes: 10diff --git a/.github/workflows/sync_files_v2.yml b/.github/workflows/sync_files_v2.ymlindex 1888c08ca7..7e6f999618 100644--- a/.github/workflows/sync_files_v2.yml+++ b/.github/workflows/sync_files_v2.yml@@ -33,6 +33,7 @@ permissions:jobs:sync-files:+ environment: bot-identityruns-on: ubuntu-lateststeps:- name: Harden Runnerdiff --git a/.github/workflows/tauri-build.yml b/.github/workflows/tauri-build.ymlindex b0888d83cf..5c04f6009f 100644--- a/.github/workflows/tauri-build.yml+++ b/.github/workflows/tauri-build.yml@@ -227,20 +227,26 @@ jobs:- name: Setup DigiCert KeyLocker Certificateif: ${{ inputs.sign && startsWith(matrix.platform, 'windows') && env.SM_API_KEY != '' && github.ref == 'refs/heads/main' }}shell: pwsh+ env:+ SM_CLIENT_CERT_FILE_B64: ${{ secrets.SM_CLIENT_CERT_FILE_B64 }}+ SM_HOST: ${{ secrets.SM_HOST }}+ SM_API_KEY: ${{ secrets.SM_API_KEY }}+ SM_CLIENT_CERT_PASSWORD: ${{ secrets.SM_CLIENT_CERT_PASSWORD }}+ SM_KEYPAIR_ALIAS: ${{ secrets.SM_KEYPAIR_ALIAS }}run: |Write-Host "Setting up DigiCert KeyLocker environment..."# Decode client certificate- $certBytes = [Convert]::FromBase64String("${{ secrets.SM_CLIENT_CERT_FILE_B64 }}")+ $certBytes = [Convert]::FromBase64String("$env:SM_CLIENT_CERT_FILE_B64")$certPath = "D:\Certificate_pkcs12.p12"[IO.File]::WriteAllBytes($certPath, $certBytes)# Set environment variablesecho "SM_CLIENT_CERT_FILE=D:\Certificate_pkcs12.p12" >> $env:GITHUB_ENV- echo "SM_HOST=${{ secrets.SM_HOST }}" >> $env:GITHUB_ENV- echo "SM_API_KEY=${{ secrets.SM_API_KEY }}" >> $env:GITHUB_ENV- echo "SM_CLIENT_CERT_PASSWORD=${{ secrets.SM_CLIENT_CERT_PASSWORD }}" >> $env:GITHUB_ENV- echo "SM_KEYPAIR_ALIAS=${{ secrets.SM_KEYPAIR_ALIAS }}" >> $env:GITHUB_ENV+ echo "SM_HOST=$env:SM_HOST" >> $env:GITHUB_ENV+ echo "SM_API_KEY=$env:SM_API_KEY" >> $env:GITHUB_ENV+ echo "SM_CLIENT_CERT_PASSWORD=$env:SM_CLIENT_CERT_PASSWORD" >> $env:GITHUB_ENV+ echo "SM_KEYPAIR_ALIAS=$env:SM_KEYPAIR_ALIAS" >> $env:GITHUB_ENV# Get PKCS11 config path from DigiCert action$pkcs11Config = $env:PKCS11_CONFIGdiff --git a/.github/workflows/testdriver.yml b/.github/workflows/testdriver.ymlindex 7c03e57967..f98d874dfa 100644--- a/.github/workflows/testdriver.yml+++ b/.github/workflows/testdriver.yml@@ -21,8 +21,12 @@ permissions:jobs:deploy:+ environment: pr-previewif: ${{ vars.CI_PROFILE != 'lite' }}runs-on: ubuntu-latest+ permissions:+ contents: read+ packages: writesteps:- name: Harden Runneruses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0@@ -66,11 +70,16 @@ jobs:VERSION=$(grep "^version =" build.gradle | awk -F'"' '{print $2}')echo "versionNumber=$VERSION" >> $GITHUB_OUTPUT- - name: Login to Docker Hub+ - name: Convert repository owner to lowercase+ id: repoowner+ run: echo "lowercase=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')" >> $GITHUB_OUTPUT++ - name: Login to GitHub Container Registryuses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0with:- username: ${{ secrets.DOCKER_HUB_USERNAME }}- password: ${{ secrets.DOCKER_HUB_API }}+ registry: ghcr.io+ username: ${{ github.actor }}+ password: ${{ github.token }}- name: Build and push test imageuses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0@@ -80,16 +89,18 @@ jobs:push: truecache-from: type=gha,scope=stirling-pdf-latestcache-to: type=gha,mode=max,scope=stirling-pdf-latest- tags: ${{ secrets.DOCKER_HUB_USERNAME }}/test:test-${{ github.sha }}+ tags: ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf-test:test-${{ github.sha }}build-args: VERSION_TAG=${{ steps.versionNumber.outputs.versionNumber }}platforms: linux/amd64- name: Set up SSHrun: |mkdir -p ~/.ssh/- echo "${{ secrets.NEW_VPS_SSH_KEY }}" > ../private.key+ echo "${NEW_VPS_SSH_KEY}" > ../private.keysudo chmod 600 ../private.key+ env:+ NEW_VPS_SSH_KEY: ${{ secrets.NEW_VPS_SSH_KEY }}- name: Deploy to VPSrun: |cat > docker-compose.yml << EOF@@ -97,7 +108,7 @@ jobs:services:stirling-pdf:container_name: stirling-pdf-test-${{ github.sha }}- image: ${{ secrets.DOCKER_HUB_USERNAME }}/test:test-${{ github.sha }}+ image: ${IMAGE_BASE}:test-${{ github.sha }}ports:- "1337:8080"volumes:@@ -118,9 +129,9 @@ jobs:restart: on-failure:5EOF- scp -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null docker-compose.yml ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }}:/tmp/docker-compose.yml+ scp -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null docker-compose.yml ${NEW_VPS_USERNAME}@${NEW_VPS_HOST}:/tmp/docker-compose.yml- ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }} << EOF+ ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${NEW_VPS_USERNAME}@${NEW_VPS_HOST} << EOFmkdir -p /stirling/test-${{ github.sha }}/{data,config,logs}mv /tmp/docker-compose.yml /stirling/test-${{ github.sha }}/docker-compose.ymlcd /stirling/test-${{ github.sha }}@@ -128,6 +139,10 @@ jobs:docker-compose up -dEOF+ env:+ IMAGE_BASE: ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf-test+ NEW_VPS_USERNAME: ${{ secrets.NEW_VPS_USERNAME }}+ NEW_VPS_HOST: ${{ secrets.NEW_VPS_HOST }}files-changed:if: always()name: detect what files changed@@ -150,6 +165,7 @@ jobs:filters: ".github/config/.files.yaml"test:+ environment: pr-previewif: needs.files-changed.outputs.frontend == 'true'needs: [deploy, files-changed]runs-on: ubuntu-latest@@ -185,6 +201,7 @@ jobs:FORCE_COLOR: "3"cleanup:+ environment: pr-previewneeds: [deploy, test]runs-on: ubuntu-latestif: always()@@ -198,16 +215,21 @@ jobs:- name: Set up SSHrun: |mkdir -p ~/.ssh/- echo "${{ secrets.NEW_VPS_SSH_KEY }}" > ../private.key+ echo "${NEW_VPS_SSH_KEY}" > ../private.keysudo chmod 600 ../private.key+ env:+ NEW_VPS_SSH_KEY: ${{ secrets.NEW_VPS_SSH_KEY }}- name: Cleanup deploymentif: always()run: |- ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }} << EOF+ ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${NEW_VPS_USERNAME}@${NEW_VPS_HOST} << EOFcd /stirling/test-${{ github.sha }}docker-compose downcd /stirlingrm -rf test-${{ github.sha }}EOF+ env:+ NEW_VPS_USERNAME: ${{ secrets.NEW_VPS_USERNAME }}+ NEW_VPS_HOST: ${{ secrets.NEW_VPS_HOST }}continue-on-error: true # Ensure cleanup runs even if previous steps fail