name: Build and Deploy Docker Images on: workflow_dispatch: inputs: ref: description: Git Ref required: true type: string jobs: build: name: build runs-on: ubuntu-latest permissions: packages: write contents: read steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 ref: ${{inputs.ref}} token: ${{ secrets.GITHUB_TOKEN }} - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Buildx uses: docker/setup-buildx-action@v3 - name: Calculate Image Tags env: INPUT_REF: ${{inputs.ref}} run: | declare TAGS="" case "${INPUT_REF}" in v[0-9]*.[0-9]*.[0-9]*) TAGS="${INPUT_REF}" if [[ "$(git rev-parse origin/main)" = "$(git rev-parse "${INPUT_REF}")" ]]; then TAGS="${TAGS} latest" fi CHANNEL="stable" ;; [0-9]*.[0-9]*.[0-9]*-nightly) TAGS="${INPUT_REF} nightly" CHANNEL="nightly" ;; *) echo "Invalid Input Ref: ${INPUT_REF}" exit 1 esac if [[ -z "${TAGS}" ]]; then echo "Empty Tags!" exit 1 fi { echo 'DOCKER_IMAGE_TAGS<> "${GITHUB_ENV}" echo "CHANNEL=${CHANNEL}" >> "${GITHUB_ENV}" cat "${GITHUB_ENV}" - name: Node uses: actions/setup-node@v4 with: node-version: 20 - name: Generate metadata run: | node scripts/generateMetadata.js --channel=${{env.CHANNEL}} - name: Build & Push uses: docker/build-push-action@v6 with: cache-from: type=gha cache-to: type=gha,mode=max platforms: linux/amd64,linux/arm64 push: true context: . file: ./Dockerfile tags: ${{env.DOCKER_IMAGE_TAGS}}