docker-image-published #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .github/workflows/update_helm_chart.yml | |
| # Updates the Helm chart when a new Docker image is published | |
| name: Update Helm Chart | |
| on: | |
| repository_dispatch: | |
| types: | |
| - docker-image-published | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to update to (e.g., v0.1.0)' | |
| required: true | |
| type: string | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| update-helm: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| chart_version: ${{ steps.chart_version.outputs.version }} | |
| updated: ${{ steps.commit.outputs.updated }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Debug - Show event payload | |
| run: | | |
| echo "Event name: ${{ github.event_name }}" | |
| echo "Client payload:" | |
| echo '${{ toJson(github.event.client_payload) }}' | |
| echo "Inputs:" | |
| echo '${{ toJson(github.event.inputs) }}' | |
| - name: Determine version | |
| id: version | |
| run: | | |
| # Check for manual input first | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| VERSION="${{ github.event.inputs.version }}" | |
| # Check for repository_dispatch payload | |
| elif [ "${{ github.event_name }}" = "repository_dispatch" ]; then | |
| VERSION="${{ github.event.client_payload.version }}" | |
| fi | |
| if [ -z "$VERSION" ]; then | |
| echo "ERROR: No version specified!" | |
| echo " github.event_name: ${{ github.event_name }}" | |
| echo " client_payload.version: ${{ github.event.client_payload.version }}" | |
| echo " inputs.version: ${{ github.event.inputs.version }}" | |
| exit 1 | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Updating to version: $VERSION" | |
| - name: Configure Git | |
| run: | | |
| git config user.name github-actions | |
| git config user.email github-actions@github.com | |
| - name: Update values.yaml with new image tag | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| # Update image tag in values.yaml | |
| sed -i "s|tag:.*|tag: \"$VERSION\"|g" charts/picoclaw/values.yaml | |
| echo "Updated values.yaml image tag to: $VERSION" | |
| grep "tag:" charts/picoclaw/values.yaml | |
| - name: Update Chart.yaml version | |
| id: chart_version | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| # Update appVersion in Chart.yaml (keep 'v' prefix to match upstream releases) | |
| sed -i "s|appVersion:.*|appVersion: \"$VERSION\"|g" charts/picoclaw/Chart.yaml | |
| # Bump chart version (patch version) | |
| CURRENT_CHART_VERSION=$(grep "^version:" charts/picoclaw/Chart.yaml | awk '{print $2}') | |
| MAJOR=$(echo $CURRENT_CHART_VERSION | cut -d. -f1) | |
| MINOR=$(echo $CURRENT_CHART_VERSION | cut -d. -f2) | |
| PATCH=$(echo $CURRENT_CHART_VERSION | cut -d. -f3) | |
| NEW_CHART_VERSION="$MAJOR.$MINOR.$((PATCH + 1))" | |
| sed -i "s|^version:.*|version: $NEW_CHART_VERSION|g" charts/picoclaw/Chart.yaml | |
| echo "Updated Chart.yaml:" | |
| echo " appVersion: $VERSION" | |
| echo " version: $NEW_CHART_VERSION" | |
| cat charts/picoclaw/Chart.yaml | |
| echo "version=$NEW_CHART_VERSION" >> $GITHUB_OUTPUT | |
| - name: Lint Helm chart | |
| run: helm lint charts/picoclaw | |
| - name: Commit changes | |
| id: commit | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| git add charts/picoclaw/Chart.yaml charts/picoclaw/values.yaml | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| echo "updated=false" >> $GITHUB_OUTPUT | |
| else | |
| git commit -m "chore: update helm chart for picoclaw $VERSION" | |
| git push | |
| echo "updated=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Package Helm chart | |
| run: | | |
| mkdir -p helm-packages | |
| helm package charts/picoclaw --destination helm-packages/ | |
| echo "CHART_FILE=$(ls helm-packages/*.tgz)" >> $GITHUB_ENV | |
| - name: Create GitHub Release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| CHART_VERSION="${{ steps.chart_version.outputs.version }}" | |
| # Check if release already exists | |
| if ! gh release view "helm-chart-$CHART_VERSION" &>/dev/null; then | |
| gh release create "helm-chart-$CHART_VERSION" \ | |
| --title "Helm Chart $CHART_VERSION (PicoClaw $VERSION)" \ | |
| --notes "## What's Changed | |
| - Updated PicoClaw to version **$VERSION** | |
| - Image tag: \`ghcr.io/${{ github.repository_owner }}/picoclaw-docker/picoclaw:$VERSION\` | |
| ## Installation | |
| \`\`\`bash | |
| # Add the Helm repository | |
| helm repo add picoclaw https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }} | |
| helm repo update | |
| # Install the chart | |
| helm install picoclaw picoclaw/picoclaw \\ | |
| -n picoclaw --create-namespace \\ | |
| --set channels.telegram.enabled=true \\ | |
| --set channels.telegram.token=\"YOUR_BOT_TOKEN\" \\ | |
| --set providers.openrouter.apiKey=\"YOUR_API_KEY\" | |
| \`\`\` | |
| ## OCI Installation (alternative) | |
| \`\`\`bash | |
| helm install picoclaw oci://ghcr.io/${{ github.repository_owner }}/picoclaw-docker/picoclaw \\ | |
| --version $CHART_VERSION \\ | |
| -n picoclaw --create-namespace | |
| \`\`\` | |
| ## Upgrade | |
| \`\`\`bash | |
| helm repo update | |
| helm upgrade picoclaw picoclaw/picoclaw -n picoclaw | |
| \`\`\` | |
| " \ | |
| ${{ env.CHART_FILE }} \ | |
| --latest | |
| echo "Created release: helm-chart-$CHART_VERSION" | |
| else | |
| echo "Release helm-chart-$CHART_VERSION already exists, skipping" | |
| fi | |
| - name: Login to GHCR | |
| run: echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin | |
| - name: Push to GHCR (OCI) | |
| run: | | |
| helm push ${{ env.CHART_FILE }} oci://ghcr.io/${{ github.repository_owner }}/picoclaw-docker | |
| echo "Published Helm chart to OCI: ${{ env.CHART_FILE }}" | |
| # Trigger the GitHub Pages deployment workflow | |
| trigger-pages: | |
| needs: update-helm | |
| if: needs.update-helm.outputs.updated == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Trigger Pages Deployment | |
| uses: peter-evans/repository-dispatch@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| event-type: helm-chart-updated |