name: Docker run-name: "Docker: ${{ github.sha }}" on: push: branches: [main] schedule: - cron: "0 6 * * *" workflow_dispatch: concurrency: group: docker-${{ github.ref }} cancel-in-progress: true jobs: build-and-push: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: ref: ${{ github.sha }} fetch-depth: 0 - name: Check upstream for new opencode image id: upstream run: | TOKEN=$(curl -s "https://ghcr.io/token?service=ghcr.io&scope=repository:anomalyco/opencode:pull" | jq -r .token) DIGEST=$(curl -s -H "Authorization: Bearer $TOKEN" \ "https://ghcr.io/v2/anomalyco/opencode/manifests/latest" \ -H "Accept: application/vnd.oci.image.index.v1+json" 2>/dev/null | jq -r '.manifests[] | select(.platform.architecture=="amd64" and .platform.os=="linux") | .digest' || echo "") echo "digest=${DIGEST}" >> "$GITHUB_OUTPUT" - name: Login to Gitea Package Registry uses: docker/login-action@v3 with: registry: gitea.steffenillium.de username: steffen password: ${{ secrets.TOKEN }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build and push uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64 push: true tags: | gitea.steffenillium.de/steffen/opencode-custom:latest gitea.steffenillium.de/steffen/opencode-custom:${{ steps.upstream.outputs.digest || github.sha }} cache-from: type=gha cache-to: type=gha,mode=max