@@ -2,11 +2,17 @@ name: Build and Publish Claude Home
22
33on :
44 push :
5- tags :
6- - ' v* '
5+ branches :
6+ - main
77 paths :
8- - ' claude-home/**'
8+ - ' claude-home/Dockerfile'
9+ - ' claude-home/build.yaml'
10+ - ' claude-home/requirements.txt'
11+ - ' claude-home/package*.json'
12+ - ' claude-home/hass-mcp-lite/**'
913 - ' .github/workflows/build-claude-home.yml'
14+ tags :
15+ - ' v*'
1016 workflow_dispatch :
1117 inputs :
1218 version :
@@ -103,4 +109,38 @@ jobs:
103109 git commit -m "Update Claude Home to ${VERSION}"
104110 git push origin update-addon-${VERSION}
105111 gh pr create --title "Update Claude Home to ${VERSION}" --body "Automated update from container build"
112+ fi
113+
114+ - name : Revert version bump on build failure
115+ if : failure()
116+ env :
117+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
118+ run : |
119+ # Only revert if this was triggered by a push to main
120+ if [[ "${{ github.event_name }}" == "push" ]] && [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
121+ echo "Build failed - checking if we need to revert version bump"
122+
123+ # Get the previous version from git history
124+ git fetch origin main
125+ PREV_VERSION=$(git show origin/main~1:claude-home/config.yaml | grep "^version:" | cut -d'"' -f2)
126+ CURRENT_VERSION=$(grep "^version:" claude-home/config.yaml | cut -d'"' -f2)
127+
128+ if [ "$PREV_VERSION" != "$CURRENT_VERSION" ]; then
129+ echo "Reverting version from $CURRENT_VERSION to $PREV_VERSION"
130+
131+ git config --global user.name 'github-actions[bot]'
132+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
133+
134+ # Create a new branch and revert
135+ git checkout -b revert-version-$CURRENT_VERSION
136+ sed -i "s/version: \"$CURRENT_VERSION\"/version: \"$PREV_VERSION\"/" claude-home/config.yaml
137+ git add claude-home/config.yaml
138+ git commit -m "Revert version to $PREV_VERSION due to build failure"
139+ git push origin revert-version-$CURRENT_VERSION
140+
141+ # Create PR
142+ gh pr create --title "Revert version to $PREV_VERSION due to build failure" \
143+ --body "The build for version $CURRENT_VERSION failed. This PR reverts the version to prevent users from seeing a broken update." \
144+ --base main
145+ fi
106146 fi
0 commit comments