name: 'OpenTelemetry-cpp dependencies image'
on:
  schedule:
    - cron: "0 3 * * 6"

permissions:
  contents: read

jobs:
  docker_image:
    name: Docker Image
    runs-on: ubuntu-latest
    timeout-minutes: 300
    steps:
    - name: Harden the runner (Audit all outbound calls)
      uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1
      with:
        egress-policy: audit

    -
      name: checkout
      uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
    -
      name: Set up QEMU
      uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
    -
      name: Set up Docker Buildx
      id: buildx
      uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
    -
      name: Build Image
      uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
      with:
        builder: ${{ steps.buildx.outputs.name }}
        context: ci/
        file: ./docker/Dockerfile
        build-args: BASE_IMAGE=ubuntu:latest
        platforms: linux/amd64
        # platforms: linux/amd64,linux/arm64
        push: false
        tags: otel-cpp-deps
        load: true
    -
      name: Save Image
      run: |
        docker images
        docker save -o /opt/otel-cpp-deps-debian.tar otel-cpp-deps
    -
      name: Upload Image
      uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
      with:
        name: otel-cpp-deps
        path: /opt/otel-cpp-deps-debian.tar
        retention-days: 14
