name: 'Gordon Deploy' description: 'Build and push container images to a Gordon registry on tag push' author: 'Gordon Contributors' branding: icon: 'upload-cloud' color: 'blue' inputs: registry: description: 'Gordon registry URL (e.g., registry.mydomain.com)' required: true username: description: 'Registry username (token subject for token auth)' required: true password: description: 'Registry password or token' required: true image: description: 'Image name (defaults to repository name)' required: false default: '' tag: description: 'Override image tag (defaults to git tag or short SHA)' required: false default: '' dockerfile: description: 'Path to Dockerfile (defaults to ./Dockerfile)' required: false default: './Dockerfile' context: description: 'Build context path (defaults to .)' required: false default: '.' build-args: description: 'Build arguments (one per line, KEY=value format)' required: false default: '' platforms: description: 'Target platforms (e.g., linux/amd64,linux/arm64)' required: false default: '' push-latest: description: 'Also push with :latest tag' required: false default: 'true' cache-from: description: 'Cache source (e.g., type=gha)' required: false default: 'type=gha' cache-to: description: 'Cache destination (e.g., type=gha,mode=max)' required: false default: 'type=gha,mode=max' outputs: image: description: 'Full image reference that was pushed' value: ${{ steps.meta.outputs.image }} tag: description: 'Tag that was pushed' value: ${{ steps.meta.outputs.tag }} digest: description: 'Image digest' value: ${{ steps.push.outputs.digest }} runs: using: 'composite' steps: - name: Validate inputs shell: bash run: | if [[ ! -f "${{ inputs.dockerfile }}" ]]; then echo "::error::Dockerfile not found at ${{ inputs.dockerfile }}" exit 1 fi - name: Extract metadata id: meta shell: bash run: | # Determine image name IMAGE_NAME="${{ inputs.image }}" if [[ -z "$IMAGE_NAME" ]]; then IMAGE_NAME="${GITHUB_REPOSITORY#*/}" fi # Extract tag from ref (or override) if [[ -n "${{ inputs.tag }}" ]]; then TAG="${{ inputs.tag }}" elif [[ "$GITHUB_REF" == refs/tags/* ]]; then TAG="${GITHUB_REF#refs/tags/}" else TAG="$(echo "$GITHUB_SHA" | head -c 7)" fi # Full image reference FULL_IMAGE="${{ inputs.registry }}/${IMAGE_NAME}:${TAG}" echo "image=${FULL_IMAGE}" >> $GITHUB_OUTPUT echo "image_name=${IMAGE_NAME}" >> $GITHUB_OUTPUT echo "tag=${TAG}" >> $GITHUB_OUTPUT echo "registry=${{ inputs.registry }}" >> $GITHUB_OUTPUT echo "Building: ${FULL_IMAGE}" - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log in to Gordon registry uses: docker/login-action@v3 with: registry: ${{ inputs.registry }} username: ${{ inputs.username }} password: ${{ inputs.password }} - name: Build tags id: tags shell: bash run: | TAGS="${{ steps.meta.outputs.image }}" if [[ "${{ inputs.push-latest }}" == "true" ]]; then TAGS="${TAGS}"$'\n'"${{ inputs.registry }}/${{ steps.meta.outputs.image_name }}:latest" fi printf "tags<> "$GITHUB_OUTPUT" - name: Build and push id: push uses: docker/build-push-action@v6 env: DOCKER_BUILD_SUMMARY: false with: context: ${{ inputs.context }} file: ${{ inputs.dockerfile }} push: true tags: ${{ steps.tags.outputs.tags }} build-args: ${{ inputs.build-args }} platforms: ${{ inputs.platforms }} cache-from: ${{ inputs.cache-from }} cache-to: ${{ inputs.cache-to }} provenance: false - name: Summary shell: bash run: | echo "## Gordon Deploy Summary" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY echo "| Image | \`${{ steps.meta.outputs.image }}\` |" >> $GITHUB_STEP_SUMMARY echo "| Tag | \`${{ steps.meta.outputs.tag }}\` |" >> $GITHUB_STEP_SUMMARY echo "| Digest | \`${{ steps.push.outputs.digest }}\` |" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "Container deployed to Gordon registry and will be automatically deployed." >> $GITHUB_STEP_SUMMARY