Show basename of script in usage text #165
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docker build and push | |
| on: | |
| push: | |
| pull_request: | |
| jobs: | |
| docker-build-and-push: | |
| name: Docker build and push | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| # This is a workaround due to | |
| # https://github.community/t/how-to-use-env-context/16975 | |
| # and https://github.com/docker/build-push-action/issues/43 | |
| - name: Set environment variables | |
| run: | | |
| DOCKER_USERNAME=matejak | |
| echo "DOCKER_USERNAME=$DOCKER_USERNAME" >> $GITHUB_ENV | |
| DOCKER_IMAGE="$DOCKER_USERNAME/argbash" | |
| echo "DOCKER_IMAGE=$DOCKER_IMAGE" >> $GITHUB_ENV | |
| if [[ "$GITHUB_REF" = refs/tags/* ]]; then | |
| version="${GITHUB_REF#refs/tags/}" | |
| DOCKER_TAGS="latest,$version" | |
| unset version | |
| elif [[ "$GITHUB_REF" = refs/pull/* ]]; then | |
| pr_number="${GITHUB_REF##*refs/pull/}" | |
| pr_number="${pr_number%%/merge*}" | |
| DOCKER_TAGS="pr-$pr_number" | |
| unset pr_number | |
| else | |
| branch="${GITHUB_REF#refs/heads/}" | |
| branch="${branch//\//-}" | |
| DOCKER_TAGS="branch-$branch" | |
| unset branch | |
| fi | |
| echo "DOCKER_TAGS=$DOCKER_TAGS" >> $GITHUB_ENV | |
| echo "The tags were set to '$DOCKER_TAGS'" | |
| # This is a workaround due to | |
| # https://github.com/docker/build-push-action/issues/85 | |
| - if: startsWith(github.ref, 'refs/pull/') | |
| name: Docker build | |
| uses: docker/build-push-action@v1 | |
| with: | |
| push: false | |
| repository: ${{ env.DOCKER_IMAGE }} | |
| dockerfile: docker/Dockerfile | |
| add_git_labels: true | |
| tags: ${{ env.DOCKER_TAGS }} | |
| tag_with_sha: true | |
| - if: "! startsWith(github.ref, 'refs/pull/')" | |
| name: Docker build and push | |
| uses: docker/build-push-action@v1 | |
| with: | |
| username: ${{ env.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| repository: ${{ env.DOCKER_IMAGE }} | |
| dockerfile: docker/Dockerfile | |
| add_git_labels: true | |
| tags: ${{ env.DOCKER_TAGS }} | |
| tag_with_sha: true | |
| - if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') | |
| name: Update Docker Hub Description | |
| uses: peter-evans/dockerhub-description@v2 | |
| env: | |
| DOCKERHUB_USERNAME: ${{ env.DOCKER_USERNAME }} | |
| DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
| DOCKERHUB_REPOSITORY: ${{ env.DOCKER_IMAGE }} | |
| README_FILEPATH: docker/README.md |