Skip to content

fix: Tanzu Troubles #214

fix: Tanzu Troubles

fix: Tanzu Troubles #214

Workflow file for this run

---
name: Nix container
on:
push:
branches:
- trunk
pull_request:
branches:
- "trunk"
paths:
- .github/workflows/**
- devenv.nix
- flake.lock
- flake.nix
- nix/**
- scripts/*
permissions:
contents: write
packages: write
pull-requests: write
statuses: read
env:
NIXPKGS_ALLOW_UNFREE: 1
PROJECT: ${{ github.repository }}
REGISTRY: ghcr.io
REGISTRY_NAMESPACE: ${{ github.repository_owner }}
REGISTRY_USERNAME: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
CONTAINER_BUILD: "true"
CONTAINER_PUBLISH: "true"
BRANCH_NAME_CURRENT: ${{ github.head_ref || github.ref_name }}
BRANCH_NAME_DEFAULT: ${{ github.event.repository.default_branch }}
defaults:
run:
shell: bash
jobs:
##################################################
# Generate a matrix of possible containers.
##################################################
matrix:
name: Matrix
runs-on: ${{ matrix.os }}
timeout-minutes: 30
continue-on-error: false
strategy:
fail-fast: true
matrix:
os:
- ubuntu-latest
steps:
- id: checkout_repository
name: Checkout repository
uses: actions/checkout@v3
- id: generate_matrix
name: Generating a matrix of container names
run: |
echo "Generating matrix of container names..."
# yamllint disable-line rule:line-length
CONTAINER_NAMES=$(find nix/oci -mindepth 1 -maxdepth 1 -type d ! -name "_template" ! -name "_disabled*" -printf "%f\n" | jq -R -s -c 'split("\n")[:-1]')
echo "${CONTAINER_NAMES}" | jq .
echo "CONTAINER_MATRIX=${CONTAINER_NAMES}" >> "$GITHUB_OUTPUT"
outputs:
container_matrix: ${{ steps.generate_matrix.outputs.CONTAINER_MATRIX }}
##################################################
# Build container images from the generated Matrix.
##################################################
nix:
# yaml-lint disable-line rule:line-length
name: ${{ matrix.container }}-${{ matrix.nix_build_system }}-${{ matrix.nix_host_system }}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
continue-on-error: false
needs: matrix
strategy:
fail-fast: false
matrix:
container: ${{ fromJson(needs.matrix.outputs.container_matrix) }}
os:
- ubuntu-latest
nix_build_system:
- "x86_64-linux"
nix_host_system:
- "x86_64-linux"
steps:
- id: checkout_repository
name: Checkout repository
uses: actions/checkout@v3
with:
lfs: false
submodules: recursive
- id: install_nix
name: "Install Nix ❄️"
uses: cachix/install-nix-action@v22
- id: cachix
name: "Enable Cachix ❄️"
uses: cachix/cachix-action@v12
with:
name: salt-labs
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- id: configure_nix
name: Configure Nix
env:
NIX_CONFIG_HOME: "~/.config/nix"
run: |
mkdir --parents "$NIX_CONFIG_HOME"
cat <<- EOF >> "$NIX_CONFIG_HOME/nix.conf"
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
EOF
- id: calver
name: Set Calver Version
uses: Nelyx/[email protected]
with:
default_branch: "refs/heads/trunk"
format: "YYYY.MM.DD"
version_prefix: ""
- id: debug
name: Display debug info
run: |
echo "##################################################"
echo "Running on ${{ matrix.os }}"
echo "REGISTRY_PATH: $REGISTRY_PATH"
echo "IMAGE_NAME: $IMAGE_NAME"
echo "BUILD SYSTEM: $BUILD_SYSTEM"
echo "HOST SYSTEM: $HOST_SYSTEM"
echo "IMAGE_TAG: $IMAGE_TAG"
echo "CONTAINER_BUILD: $CONTAINER_BUILD"
echo "CONTAINER_PUBLISH: $CONTAINER_PUBLISH"
echo "Nix conf:"
cat "${HOME}/.config/nix/nix.conf"
echo "##################################################"
env:
REGISTRY_PATH: "${{ env.REGISTRY }}/${{ env.PROJECT }}"
IMAGE_NAME: ${{ matrix.container }}
BUILD_SYSTEM: ${{ matrix.nix_build_system }}
HOST_SYSTEM: ${{ matrix.nix_host_system }}
IMAGE_TAG: "${{ steps.calver.outputs.package_version }}"
- id: publish_container_latest
name: "Publish container image ${{ matrix.container }}:latest"
if: env.BRANCH_NAME_CURRENT != env.BRANCH_NAME_DEFAULT
run: ./scripts/oci.sh
env:
REGISTRY_PATH: "${{ env.REGISTRY }}/${{ env.PROJECT }}"
IMAGE_NAME: ${{ matrix.container }}
BUILD_SYSTEM: ${{ matrix.nix_build_system }}
HOST_SYSTEM: ${{ matrix.nix_host_system }}
IMAGE_TAG: "latest"
- id: publish_container_release
# yaml-lint disable-line rule:line-length
name: "Publish container image ${{ matrix.container }}:${{ steps.calver.outputs.package_version }}"
if: env.BRANCH_NAME_CURRENT == env.BRANCH_NAME_DEFAULT
run: ./scripts/oci.sh
env:
REGISTRY_PATH: "${{ env.REGISTRY }}/${{ env.PROJECT }}"
IMAGE_NAME: ${{ matrix.container }}
BUILD_SYSTEM: ${{ matrix.nix_build_system }}
HOST_SYSTEM: ${{ matrix.nix_host_system }}
IMAGE_TAG: "${{ steps.calver.outputs.package_version }}"
##################################################
# Giphy thumbs up or down
##################################################
thumbs:
name: Thumbs Up
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: true
matrix:
os:
- ubuntu-latest
needs: nix
steps:
- id: pr-status-giphy
name: PR Status Giphy
if: github.event_name == 'pull_request'
uses: dgteixeira/pr-status-giphy-action@v2
env:
GIPHY_API_KEY: ${{ secrets.GIPHY_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}