aboutsummaryrefslogtreecommitdiff
path: root/src/secp256k1/.github/actions/run-in-docker-action/action.yml
blob: 74933686a0f3c0b88786dfc9db1eeaf495284bcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: 'Run in Docker with environment'
description: 'Run a command in a Docker container, while passing explicitly set environment variables into the container.'
inputs:
  dockerfile:
    description: 'A Dockerfile that defines an image'
    required: true
  tag:
    description: 'A tag of an image'
    required: true
  command:
    description: 'A command to run in a container'
    required: false
    default: ./ci/ci.sh
runs:
  using: "composite"
  steps:
    - uses: docker/setup-buildx-action@v3

    - uses: docker/build-push-action@v5
      id: main_builder
      continue-on-error: true
      with:
        context: .
        file: ${{ inputs.dockerfile }}
        tags: ${{ inputs.tag }}
        load: true
        cache-from: type=gha

    - uses: docker/build-push-action@v5
      id: retry_builder
      if: steps.main_builder.outcome == 'failure'
      with:
        context: .
        file: ${{ inputs.dockerfile }}
        tags: ${{ inputs.tag }}
        load: true
        cache-from: type=gha

    - # Workaround for https://github.com/google/sanitizers/issues/1614 .
      # The underlying issue has been fixed in clang 18.1.3.
      run: sudo sysctl -w vm.mmap_rnd_bits=28
      shell: bash

    - # Tell Docker to pass environment variables in `env` into the container.
      run: >
        docker run \
          $(echo '${{ toJSON(env) }}' | jq -r 'keys[] | "--env \(.) "') \
          --volume ${{ github.workspace }}:${{ github.workspace }} \
          --workdir ${{ github.workspace }} \
          ${{ inputs.tag }} bash -c "
            git config --global --add safe.directory ${{ github.workspace }}
            ${{ inputs.command }}
          "
      shell: bash