diff --git a/.gitea/workflows/portainer_automation_build_push.yml b/.gitea/workflows/portainer_automation_build_push.yml index 8ce4c0f..e8fa2ae 100644 --- a/.gitea/workflows/portainer_automation_build_push.yml +++ b/.gitea/workflows/portainer_automation_build_push.yml @@ -7,15 +7,6 @@ on: - test # → PATCH bump, build & tag as test - main # → MINOR bump, promote test→prod workflow_dispatch: - inputs: - environment: - description: 'Target environment (test → PATCH bump, prod → MINOR bump)' - required: true - default: 'test' - type: choice - options: - - test - - prod jobs: version: @@ -31,15 +22,9 @@ jobs: - name: Determine environment id: env run: | - if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then - ENV="${{ inputs.environment }}" - else - # Push events: test branch → test env, main branch → prod env - [[ "${{ github.ref_name }}" == "main" ]] && ENV="prod" || ENV="${{ github.ref_name }}" - fi - # Validate + [[ "${{ github.ref_name }}" == "main" ]] && ENV="prod" || ENV="${{ github.ref_name }}" if [[ "$ENV" != "test" && "$ENV" != "prod" ]]; then - echo "❌ Invalid environment: $ENV. Must be 'test' or 'prod'." + echo "→ Invalid environment: $ENV. Must be 'test' or 'prod'." exit 1 fi echo "target_env=$ENV" >> $GITHUB_OUTPUT @@ -47,8 +32,10 @@ jobs: - name: Calculate semver bump id: semver run: | - VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0") + VERSION=$(git describe --tags --match "pa-*" --abbrev=0 2>/dev/null || echo "pa-0.0.0") echo "Latest tag: ${VERSION}" + # Strip pa- prefix + VERSION=${VERSION#pa-} MAJOR=$(echo ${VERSION} | cut -d "." -f 1) MINOR=$(echo ${VERSION} | cut -d "." -f 2) PATCH=$(echo ${VERSION} | cut -d "." -f 3) @@ -64,7 +51,7 @@ jobs: NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}" echo "Test → patch bump: ${NEW_VERSION}" fi - echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT + echo "new_version=pa-${NEW_VERSION}" >> $GITHUB_OUTPUT build-and-push: runs-on: ubuntu-latest @@ -108,13 +95,13 @@ jobs: REG="192.168.0.100:8928/hithomelabs/portainer-automation" if [[ "$ENV" == "test" ]]; then - echo "🔨 Building fresh image for test" + echo "→ Building fresh image for test" ./gradlew :portainer-automation:bootBuildImage --imageName="${REG}:${VER}" docker tag "${REG}:${VER}" "${REG}:test" docker push "${REG}:test" docker push "${REG}:${VER}" else - echo "♻️ Promoting test image to prod" + echo "→ Promoting test image to prod" docker pull "${REG}:test" docker tag "${REG}:test" "${REG}:${VER}" docker tag "${REG}:${VER}" "${REG}:prod"