name: Build & push image # Builds the gadfly-reports daemon image and pushes it to the Gitea container # registry so it's easy to self-host. # # push to main -> :latest + :sha- # push tag v* -> : + :latest # # Required repo secrets: REGISTRY_USER / REGISTRY_PASSWORD (registry push). The # Go build uses only PUBLIC modules, so no private-module creds are needed. on: push: branches: [main] tags: ["v*"] paths-ignore: - "**.md" - "LICENSE" - ".gitignore" - ".env.example" workflow_dispatch: {} concurrency: group: gadfly-reports-image-${{ github.ref }} cancel-in-progress: true env: IMAGE_NAME: gitea.stevedudenhoeffer.com/steve/gadfly-reports jobs: build-and-push: runs-on: ubuntu-latest timeout-minutes: 20 steps: - uses: actions/checkout@v4 - name: Set up Docker Buildx run: docker buildx create --use --name gr-builder --driver docker-container 2>/dev/null || docker buildx use gr-builder - name: Log in to the registry env: REGISTRY_USER: ${{ secrets.REGISTRY_USER }} REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} run: echo "${REGISTRY_PASSWORD}" | docker login gitea.stevedudenhoeffer.com -u "${REGISTRY_USER}" --password-stdin - name: Compute tags id: meta run: | SHA_SHORT=$(echo "${GITHUB_SHA}" | cut -c1-7) if [ "${{ github.ref_type }}" = "tag" ]; then TAGS="${IMAGE_NAME}:${GITHUB_REF_NAME},${IMAGE_NAME}:latest" else TAGS="${IMAGE_NAME}:latest,${IMAGE_NAME}:sha-${SHA_SHORT}" fi echo "tags=${TAGS}" >> "$GITHUB_OUTPUT" echo "Tags: ${TAGS}" - name: Build and push run: | TAG_FLAGS="" IFS=',' read -ra TAG_ARRAY <<< "${{ steps.meta.outputs.tags }}" for t in "${TAG_ARRAY[@]}"; do TAG_FLAGS="$TAG_FLAGS --tag $t"; done docker buildx build \ --push \ --platform linux/amd64 \ $TAG_FLAGS \ --add-host gitea.stevedudenhoeffer.com:192.168.0.134 \ --file ./Dockerfile \ .