"Fossies" - the Fresh Open Source Software Archive

Member "argbash-2.10.0/.github/workflows/docker-build-and-push.yaml" (22 Sep 2020, 2602 Bytes) of package /linux/privat/argbash-2.10.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ansible YAML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "docker-build-and-push.yaml": 2.9.0_vs_2.10.0.

    1 name: Docker build and push
    2 
    3 on:
    4   push:
    5   pull_request:
    6 
    7 jobs:
    8   docker-build-and-push:
    9     name: Docker build and push
   10 
   11     runs-on: ubuntu-latest
   12 
   13     steps:
   14       - uses: actions/checkout@v2
   15       
   16       # This is a workaround due to
   17       # https://github.community/t/how-to-use-env-context/16975
   18       # and https://github.com/docker/build-push-action/issues/43
   19       - name: Set environment variables
   20         run: |
   21           DOCKER_USERNAME=matejak
   22           echo "::set-env name=DOCKER_USERNAME::$DOCKER_USERNAME"
   23           
   24           DOCKER_IMAGE="$DOCKER_USERNAME/argbash"
   25           echo "::set-env name=DOCKER_IMAGE::$DOCKER_IMAGE"
   26 
   27           if [[ "$GITHUB_REF" = refs/tags/* ]]; then
   28             version="${GITHUB_REF#refs/tags/}"
   29             DOCKER_TAGS="latest,$version"
   30             unset version
   31           elif [[ "$GITHUB_REF" = refs/pull/* ]]; then
   32             pr_number="${GITHUB_REF##*refs/pull/}"
   33             pr_number="${pr_number%%/merge*}"
   34             DOCKER_TAGS="pr-$pr_number"
   35             unset pr_number
   36           else
   37             branch="${GITHUB_REF#refs/heads/}"
   38             branch="${branch//\//-}"
   39             DOCKER_TAGS="branch-$branch"
   40             unset branch
   41           fi
   42           echo "::set-env name=DOCKER_TAGS::$DOCKER_TAGS"
   43           echo "The tags were set to '$DOCKER_TAGS'"
   44 
   45       # This is a workaround due to
   46       # https://github.com/docker/build-push-action/issues/85
   47       - if: startsWith(github.ref, 'refs/pull/')
   48         name: Docker build
   49         uses: docker/build-push-action@v1
   50         with:
   51           push: false
   52           repository: ${{ env.DOCKER_IMAGE }}
   53           dockerfile: docker/Dockerfile
   54           add_git_labels: true
   55           tags: ${{ env.DOCKER_TAGS }}
   56           tag_with_sha: true
   57 
   58       - if: "! startsWith(github.ref, 'refs/pull/')"
   59         name: Docker build and push
   60         uses: docker/build-push-action@v1
   61         with:
   62           username: ${{ env.DOCKER_USERNAME }}
   63           password: ${{ secrets.DOCKER_PASSWORD }}
   64           repository: ${{ env.DOCKER_IMAGE }}
   65           dockerfile: docker/Dockerfile
   66           add_git_labels: true
   67           tags: ${{ env.DOCKER_TAGS }}
   68           tag_with_sha: true
   69 
   70       - if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
   71         name: Update Docker Hub Description
   72         uses: peter-evans/dockerhub-description@v2
   73         env:
   74           DOCKERHUB_USERNAME: ${{ env.DOCKER_USERNAME }}
   75           DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
   76           DOCKERHUB_REPOSITORY: ${{ env.DOCKER_IMAGE }}
   77           README_FILEPATH: docker/README.md