aboutsummaryrefslogtreecommitdiff
path: root/src/secp256k1/.github/actions/run-in-docker-action/action.yml
blob: dbfaa4fecef81ad530861122c69fe97fcdc83758 (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
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

    - # 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