name: Publish Docker Image on: push: tags: - 'v*' jobs: build-base: runs-on: ubuntu-latest container: image: catthehacker/ubuntu:act-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Force IPv4 for Docker Hub run: | # Prefer IPv4 to avoid intermittent IPv6 connectivity failures echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf - name: Set up QEMU uses: docker/setup-qemu-action@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 with: driver-opts: network=host - name: Login to Docker Hub uses: docker/login-action@v4 with: username: ${{ vars.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Extract version from tag id: version run: | VERSION=${GITHUB_REF#refs/tags/} echo "version=${VERSION}" >> $GITHUB_OUTPUT - name: Build and push (base) uses: docker/build-push-action@v7 with: context: . platforms: linux/amd64,linux/arm64 push: true tags: | ${{ vars.DOCKERHUB_USERNAME }}/opencode-devbox:${{ steps.version.outputs.version }} ${{ vars.DOCKERHUB_USERNAME }}/opencode-devbox:latest build-omos: runs-on: ubuntu-latest container: image: catthehacker/ubuntu:act-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Force IPv4 for Docker Hub run: | # Prefer IPv4 to avoid intermittent IPv6 connectivity failures echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf - name: Set up QEMU uses: docker/setup-qemu-action@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 with: driver-opts: network=host - name: Login to Docker Hub uses: docker/login-action@v4 with: username: ${{ vars.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Extract version from tag id: version run: | VERSION=${GITHUB_REF#refs/tags/} echo "version=${VERSION}" >> $GITHUB_OUTPUT - name: Build and push (omos) uses: docker/build-push-action@v7 with: context: . platforms: linux/amd64,linux/arm64 push: true build-args: | INSTALL_OMOS=true tags: | ${{ vars.DOCKERHUB_USERNAME }}/opencode-devbox:${{ steps.version.outputs.version }}-omos ${{ vars.DOCKERHUB_USERNAME }}/opencode-devbox:latest-omos update-description: runs-on: ubuntu-latest needs: [build-base, build-omos] container: image: catthehacker/ubuntu:act-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Update Docker Hub description run: | TOKEN=$(curl -s -X POST https://hub.docker.com/v2/users/login/ \ -H "Content-Type: application/json" \ -d '{"username":"${{ vars.DOCKERHUB_USERNAME }}","password":"${{ secrets.DOCKERHUB_TOKEN }}"}' \ | jq -r .token) if [ "$TOKEN" = "null" ] || [ -z "$TOKEN" ]; then echo "::error::Failed to authenticate with Docker Hub API" exit 1 fi HTTP_CODE=$(jq -n \ --rawfile full DOCKER_HUB.md \ --arg short "Portable AI dev environment for opencode. Debian-based with git, Node.js, AWS CLI, and SSH support." \ '{"full_description": $full, "description": $short}' | \ curl -s -o /tmp/hub-response.txt -w "%{http_code}" -X PATCH \ "https://hub.docker.com/v2/repositories/${{ vars.DOCKERHUB_USERNAME }}/opencode-devbox/" \ -H "Authorization: JWT $TOKEN" \ -H "Content-Type: application/json" \ -d @-) echo "Docker Hub API returned: $HTTP_CODE" if [ "$HTTP_CODE" != "200" ]; then echo "Response body:" cat /tmp/hub-response.txt echo "::error::Docker Hub description update failed with HTTP $HTTP_CODE" exit 1 fi