docker #36
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 | |
| on: | |
| workflow_dispatch: | |
| release: | |
| types: [published] | |
| env: | |
| IMAGE_NAME: "scworkflow" # must be lowercase | |
| CONTEXT: "./" | |
| NAMESPACE: "nciccbr" | |
| permissions: read-all | |
| jobs: | |
| build-docker: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Prepare build-time variables | |
| id: vars | |
| run: | | |
| echo "DATE=$(date +"%Y-%m-%d")" >> "$GITHUB_OUTPUT" | |
| if [ '${{ github.event_name }}' == 'release' ]; then | |
| VERSION=${{ github.ref_name }} | |
| DOCKER_TAGS=${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:${VERSION},${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:latest | |
| else | |
| HASH=$(git rev-parse --short HEAD) | |
| VERSION="$(grep 'Version:' $CONTEXT/DESCRIPTION | sed 's/Version: /v/')_${HASH}" | |
| DOCKER_TAGS=${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:${VERSION} | |
| fi | |
| echo "VERSION_TAG=$(echo $VERSION)" >> "$GITHUB_OUTPUT" | |
| echo "DOCKER_TAGS=$(echo $DOCKER_TAGS)" >> "$GITHUB_OUTPUT" | |
| - name: debug | |
| run: | | |
| echo "the github tag is ${{ github.ref_name }}" | |
| echo "github event_name is ${{ github.event_name }}" | |
| echo "the version tag is ${{ steps.vars.outputs.VERSION_TAG }}" | |
| - name: Login to DockerHub | |
| if: ${{ github.event_name != 'pull_request' }} | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v4 | |
| with: | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.vars.outputs.DOCKER_TAGS }} # include 'latest' tag if this is a release | |
| context: ${{ env.CONTEXT }} | |
| file: ${{ env.CONTEXT }}/Dockerfile | |
| build-args: | | |
| BUILD_DATE=${{ steps.vars.outputs.DATE }} | |
| BUILD_TAG=${{ steps.vars.outputs.VERSION_TAG }} | |
| REPONAME=${{ env.IMAGE_NAME }} | |
| R_VERSION=4.3.2 |