Check OpenCode Version #19
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: Check OpenCode Version | |
| on: | |
| schedule: | |
| - cron: '0 12 * * *' # Daily at 12pm UTC (offset from Pi at 11am) | |
| workflow_dispatch: # Allow manual trigger | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository_owner }}/agent-sandbox-opencode | |
| jobs: | |
| check-version: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: read | |
| actions: write # Needed to trigger workflows | |
| steps: | |
| - name: Get latest OpenCode version from npm | |
| id: npm | |
| run: | | |
| VERSION=$(npm view opencode-ai@latest version 2>/dev/null) | |
| if [ -z "$VERSION" ]; then | |
| echo "Failed to fetch version from npm" | |
| exit 1 | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Latest npm version: $VERSION" | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check if version tag exists in registry | |
| id: check | |
| run: | | |
| TAG="opencode-${{ steps.npm.outputs.version }}" | |
| IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${TAG}" | |
| # Use docker manifest inspect to check if tag exists (no pull required) | |
| if docker manifest inspect "$IMAGE" > /dev/null 2>&1; then | |
| echo "Tag $TAG already exists" | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Tag $TAG does not exist" | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Trigger image rebuild | |
| if: steps.check.outputs.exists == 'false' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| echo "Triggering build-images workflow for OpenCode ${{ steps.npm.outputs.version }}..." | |
| gh workflow run build-images.yml --repo ${{ github.repository }} | |
| - name: Summary | |
| run: | | |
| echo "## OpenCode Version Check" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Check | Value |" >> $GITHUB_STEP_SUMMARY | |
| echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| npm latest | ${{ steps.npm.outputs.version }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Tag exists | ${{ steps.check.outputs.exists }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Rebuild triggered | ${{ steps.check.outputs.exists == 'false' }} |" >> $GITHUB_STEP_SUMMARY |