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@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
      with:
        egress-policy: audit

    -
      name: checkout
      uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
    -
      name: Set up QEMU
      uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
    -
      name: Set up Docker Buildx
      id: buildx
      uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
    -
      name: Build Image
      uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.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
