git.delta.rocks / unique-network / refs/heads / master

difftreelog

source

.github/actions/buildContainer/action.yml2.1 KiBsourcehistory
1name: Build or pull container2description: ''3inputs:4  container:5    description: Which name to fetch/push6    required: true7  tag:8    description: Which tag to fetch/push9    required: true10  context:11    description: Container context12    required: true13    default: "."14  dockerfile:15    description: Path to dockerfile (relative to context)16    required: true17  args:18    description: Docker build extra args19    default: ''20  dockerhub_username:21    description: Secret22  dockerhub_token:23    description: Secret24outputs:25  name:26    description: Full container name27    value: ${{ steps.ensure.outputs.name }}28runs:29  using: "composite"30  steps:31    - name: Ensure have ${{ inputs.container }}:${{ inputs.tag }}32      id: ensure33      run: |34        echo "Wanted container: ${{ inputs.container }}:${{ inputs.tag }}"3536        TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${{ inputs.dockerhub_username }}'", "password": "'${{ inputs.dockerhub_token }}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)3738        # Get TAGS from DOCKERHUB39        TAGS=$(curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/${{ inputs.container }}/tags/?page_size=100 | jq -r '."results"[]["name"]' || echo "")4041        echo "Available tags:"42        echo "$TAGS"4344        # Check correct version POLKADOT and build it if it doesn't exist in POLKADOT TAGS45        if [[ ${TAGS[*]} =~ (^|[[:space:]])"${{ inputs.tag }}"($|[[:space:]]) ]]; then46          echo "Repository has needed version, pulling";47          docker pull ${{ inputs.container }}:${{ inputs.tag }}48        else49          echo "Repository had no needed version, so build it";50          cd "${{ inputs.context }}" && docker build --file "${{ inputs.dockerfile }}" \51            $BUILD_ARGS --tag ${{ inputs.container }}:${{ inputs.tag }} \52            .53          echo "Push built version to the repository";54          docker push ${{ inputs.container }}:${{ inputs.tag }} || true55        fi56        echo "name=${{ inputs.container }}:${{ inputs.tag }}" >> $GITHUB_OUTPUT57      env:58        BUILD_ARGS: ${{ inputs.args }}59      shell: bash