Skip to content

Rebuild Tagged Releases #64

Rebuild Tagged Releases

Rebuild Tagged Releases #64

name: Rebuild Tagged Releases
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Runs at midnight every day
permissions:
contents: read
packages: write
jobs:
list-tags:
name: List .RELEASE tags
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.list_tags.outputs.tags }}
steps:
- name: Check out the repo
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: List all .RELEASE tags
id: list_tags
run: |
tags=$(git ls-remote --tags --refs | grep -o 'refs/tags/.*\.RELEASE$' | sed 's#refs/tags/##' | jq -c -R -s 'split("\n") | map(select(length > 0))')
echo "tags=${tags}" >> $GITHUB_OUTPUT
rebuild-ghcr:
name: Rebuild and Push to GHCR
runs-on: ubuntu-latest
needs: list-tags
if: needs.list-tags.outputs.tags != '[]'
strategy:
fail-fast: false
matrix:
tag: ${{ fromJson(needs.list-tags.outputs.tags) }}
steps:
- name: Check out the repo at a specific tag
uses: actions/checkout@v6
with:
ref: ${{ matrix.tag }}
- name: Log in to the GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ matrix.tag }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./switchbot-mcp-server/src/main/docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
provenance: true
sbom: true
rebuild-quay:
name: Rebuild and Push to Quay
runs-on: ubuntu-latest
needs: list-tags
if: needs.list-tags.outputs.tags != '[]'
strategy:
fail-fast: false
matrix:
tag: ${{ fromJson(needs.list-tags.outputs.tags) }}
env:
REGISTRY: quay.io
IMAGE: sharplab/switchbot-mcp-server
steps:
- name: Check out the repo at a specific tag
uses: actions/checkout@v6
with:
ref: ${{ matrix.tag }}
- name: Log in to Quay.io
uses: redhat-actions/podman-login@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.QUAY_BOT_USERNAME }}
password: ${{ secrets.QUAY_BOT_TOKEN }}
- name: Build image (buildah)
id: build_image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE }}
tags: ${{ matrix.tag }}
containerfiles: |
./switchbot-mcp-server/src/main/docker/Dockerfile
context: .
- name: Push to Quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.REGISTRY }}