aoh

A tool for running Ansible playbooks with `curl <url> | python` commands
git clone https://git.ashermorgan.net/aoh/
Log | Files | Refs | README

ci-cd.yml (3944B)


      1 name: AoH CI/CD
      2 
      3 on:
      4   push:
      5     paths-ignore:
      6       - README.md
      7 
      8   pull_request:
      9     paths-ignore:
     10       - README.md
     11 
     12 env:
     13   REGISTRY: ghcr.io
     14   IMAGE_NAME: ${{ github.repository }}
     15 
     16 jobs:
     17   run-unit-tests:
     18     runs-on: ubuntu-latest
     19 
     20     steps:
     21       - uses: actions/checkout@v6
     22 
     23       - name: Set up Python
     24         uses: actions/setup-python@v5
     25         with:
     26           python-version: '3.14'
     27 
     28       - name: Install dependencies
     29         run: |
     30           python -m pip install --upgrade pip
     31           pip install -r requirements.txt
     32 
     33       - name: Run unit tests
     34         run: python -m unittest tests.unit
     35 
     36 
     37   run-e2e-tests-linux:
     38     runs-on: ubuntu-latest
     39 
     40     steps:
     41       - uses: actions/checkout@v6
     42 
     43       - name: Run end-to-end tests
     44         run: ./tests/e2e/run.sh
     45 
     46 
     47   run-e2e-tests-windows:
     48     runs-on: windows-2025
     49 
     50     env:
     51       DOCKER_HOST: tcp://127.0.0.1:2375
     52 
     53     steps:
     54       - name: Clone repository
     55         uses: actions/checkout@v6
     56 
     57       - name: Replace symlinks with copies
     58         run: |
     59           Remove-Item -LiteralPath .\aoh\templates\client.py -Force
     60           Copy-Item -LiteralPath .\aoh\client.py -Destination .\aoh\templates\client.py
     61 
     62       - name: Install Alpine Linux in WSL
     63         run: |
     64           wsl --install --no-distribution
     65           $url = "https://dl-cdn.alpinelinux.org/alpine/v3.24/releases/x86_64/alpine-minirootfs-3.24.2-x86_64.tar.gz"
     66           Invoke-WebRequest -Uri $url -OutFile alpine.tar.gz
     67           wsl --install --name Alpine --from-file alpine.tar.gz
     68 
     69       - name: Install Docker in WSL
     70         run: |
     71           wsl -d Alpine -- apk update
     72           wsl -d Alpine -- apk add docker
     73           wsl -d Alpine -- sh -c 'mkdir -p /etc/docker && echo "{\"hosts\": [\"tcp://127.0.0.1:2375\", \"unix:///var/run/docker.sock\"]}" > /etc/docker/daemon.json'
     74 
     75       - name: Start dockerd in WSL
     76         run: |
     77           wsl -d Alpine -- sh -c 'nohup sleep infinity > /dev/null 2>&1 &'
     78           wsl -d Alpine -- sh -c 'nohup dockerd > /var/log/dockerd.log 2>&1 & sleep 15 && docker info'
     79 
     80       - name: Install Docker and Python
     81         run: choco install docker-cli python3 -y
     82 
     83       - name: Run end-to-end tests
     84         shell: powershell
     85         run: ./tests/e2e/run.ps1
     86 
     87 
     88   build-and-push-image:
     89     runs-on: ubuntu-latest
     90 
     91     if: github.ref == 'refs/heads/master'
     92 
     93     needs:
     94       - run-unit-tests
     95       - run-e2e-tests-linux
     96       - run-e2e-tests-windows
     97 
     98     permissions:
     99       contents: read
    100       packages: write
    101       attestations: write
    102       id-token: write
    103 
    104     steps:
    105       - name: Checkout repository
    106         uses: actions/checkout@v6
    107 
    108       - name: Log in to the Container registry
    109         uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
    110         with:
    111           registry: ${{ env.REGISTRY }}
    112           username: ${{ github.actor }}
    113           password: ${{ secrets.GITHUB_TOKEN }}
    114 
    115       - name: Extract metadata (tags, labels) for Docker
    116         id: meta
    117         uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
    118         with:
    119           images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
    120           tags: |
    121             type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
    122 
    123       - name: Set up QEMU
    124         uses: docker/setup-qemu-action@v4
    125 
    126       - name: Set up Docker Buildx
    127         uses: docker/setup-buildx-action@v4
    128 
    129       - name: Build and push Docker image
    130         id: push
    131         uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
    132         with:
    133           context: .
    134           platforms: linux/amd64,linux/arm64
    135           push: true
    136           tags: ${{ steps.meta.outputs.tags }}
    137           labels: ${{ steps.meta.outputs.labels }}
    138 
    139       - name: Generate artifact attestation
    140         uses: actions/attest@v4
    141         with:
    142           subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
    143           subject-digest: ${{ steps.push.outputs.digest }}
    144           push-to-registry: true