name: "Build and Push Image" on: workflow_dispatch: inputs: app: type: string description: "App to build, e.g. 'home-assistant'" required: true jobs: build-and-push: runs-on: ci-os steps: - name: Checkout uses: actions/checkout@v4 - id: set-context name: Determine build context run: | context_dir="/workspace/pub/containers/apps/${{ github.event.inputs.app }}" echo "context_dir=$context_dir" >> $GITHUB_OUTPUT - id: parse-channel-platform name: Read channel + platform from metadata.yaml shell: bash run: | metadata_file="${{ steps.set-context.outputs.context_dir }}/metadata.yaml" echo "Looking for ${metadata_file}..." if [ ! -f "$metadata_file" ]; then echo "metadata.yaml not found at $metadata_file" exit 1 fi # Grab the FIRST channel name: channel=$(yq '.channels[0].name' "$metadata_file") # Grab the FIRST platform under that channel: platform=$(yq '.channels[0].platforms[0]' "$metadata_file") echo "Using channel='$channel' and platform='$platform'" # Expose for later steps echo channel=$channel >> $GITHUB_OUTPUT echo platform=$platform >> $GITHUB_OUTPUT - id: read-version name: Read version from version.sh shell: bash run: | version=$(bash "${{ steps.set-context.outputs.context_dir }}/ci/version.sh" || echo "" | sed 's/[^a-zA-Z0-9._-]//g') echo "Discovered version: $version" echo version=$version >> $GITHUB_OUTPUT - name: Log chosen channel/platform run: | echo "Channel: ${{ steps.parse-channel-platform.outputs.channel }}" echo "Platform: ${{ steps.parse-channel-platform.outputs.platform }}" echo "Version: ${{ steps.read-version.outputs.version }}" - name: Build and Push with Kaniko uses: https://code.252.no/pub/kaniko-action@latest with: # Path that holds Dockerfile, metadata.yaml, etc. context: ${{ steps.set-context.outputs.context_dir }} # Build & push two tags: : and : destinations: code.252.no/${{ github.repository }}/${{ github.event.inputs.app }}:${{ steps.parse-channel-platform.outputs.channel }} code.252.no/${{ github.repository }}/${{ github.event.inputs.app }}:${{ steps.read-version.outputs.version }} # Pass any build arguments the Dockerfile expects build_args: | TARGETPLATFORM=${{ steps.parse-channel-platform.outputs.platform }} VERSION=${{ steps.read-version.outputs.version }} credentials: "code.252.no=tommy:${{ secrets.REGISTRY_TOKEN }}" push: "true" cache: "false"