9191 env :
9292 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
9393 run : |
94- if [ "${{ github.ref_name }}" = "main" ]; then
94+ if [ "${{ github.event_name }}" = "pull_request" ]; then
95+ # For PRs, use pr-NUMBER format
96+ echo "VERSION=pr-${{ github.event.number }}" >> $GITHUB_ENV
97+ echo "SHOULD_RELEASE=false" >> $GITHUB_ENV
98+ elif [ "${{ github.ref_name }}" = "main" ]; then
9599 # Get semantic version for main branch
96100 VERSION=$(npx semantic-release --no-ci --dry-run --branch main 2>&1 | grep -oP 'The next release version is \K[0-9]+\.[0-9]+\.[0-9]+' || echo "")
97101 if [ -z "$VERSION" ]; then
@@ -103,8 +107,9 @@ jobs:
103107 echo "SHOULD_RELEASE=true" >> $GITHUB_ENV
104108 fi
105109 else
106- # Use branch name for develop
107- echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
110+ # Use branch name for develop (sanitize it)
111+ CLEAN_BRANCH=$(echo "${{ github.ref_name }}" | sed 's/[^a-zA-Z0-9.-]/-/g')
112+ echo "VERSION=$CLEAN_BRANCH" >> $GITHUB_ENV
108113 echo "SHOULD_RELEASE=false" >> $GITHUB_ENV
109114 fi
110115 echo "Detected VERSION: $VERSION"
@@ -123,8 +128,14 @@ jobs:
123128 echo "${{ secrets.GHCR_PAT }}" > github_token
124129 export GITHUB_TOKEN="${{ secrets.GHCR_PAT }}"
125130
126- # Build and push to both registries
127- ./build-enhanced --push --ghcr --public-ecr --platform linux/arm64,linux/amd64 tiny micro full
131+ if [ "${{ github.event_name }}" = "pull_request" ]; then
132+ # For PRs, only build (don't push)
133+ echo "PR build - testing only, not pushing"
134+ ./build-enhanced --load --platform linux/arm64 tiny micro full
135+ else
136+ # For push events, build and push to both registries
137+ ./build-enhanced --push --ghcr --public-ecr --platform linux/arm64,linux/amd64 tiny micro full
138+ fi
128139
129140 # Also tag latest for main branch releases
130141 if [ "${{ github.ref_name }}" = "main" ] && [ "$SHOULD_RELEASE" = "true" ]; then
0 commit comments