build-new-release #9
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
| name: Build and Push Docker Image | |
| on: | |
| repository_dispatch: | |
| types: [build-new-release] | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }}/picoclaw | |
| jobs: | |
| build-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| # Checkout YOUR repo (contains the patch script) | |
| - name: Checkout your repository (tools) | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| path: self | |
| # Checkout upstream repo to build | |
| - name: Checkout upstream repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: sipeed/picoclaw | |
| ref: ${{ github.event.client_payload.version }} | |
| path: upstream | |
| - name: Patch upstream Dockerfile (Go + non-root) | |
| run: | | |
| python3 self/.github/scripts/patch_picoclaw_dockerfile.py upstream/Dockerfile upstream/go.mod | |
| echo "Dockerfile key lines:" | |
| grep -nE '^(FROM|USER|WORKDIR|ENTRYPOINT)|/home/picoclaw|PICOCLAW_' upstream/Dockerfile || true | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: upstream | |
| push: true | |
| tags: | | |
| ghcr.io/${{ github.repository }}/picoclaw:${{ github.event.client_payload.version }} | |
| ghcr.io/${{ github.repository }}/picoclaw:latest | |
| - name: Update version tracking | |
| working-directory: self | |
| run: | | |
| echo "${{ github.event.client_payload.version }}" > .last-build-version | |
| git config user.name github-actions | |
| git config user.email github-actions@github.com | |
| git add .last-build-version | |
| git commit -m "Built version ${{ github.event.client_payload.version }}" | |
| git push | |
| - name: Trigger Helm Chart Update | |
| if: success() | |
| uses: peter-evans/repository-dispatch@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| event-type: docker-image-published | |
| client-payload: | | |
| {"version": "${{ github.event.client_payload.version }}"} |