Skip to content

Use .NET 8 docker building tooling #242

@bruno-garcia

Description

@bruno-garcia

There's a lot of yml dealing with building the docker images:

- name: Prepare Docker
id: docker-prep
run: |
DOCKER_IMAGE=nugettrends/nugettrends.scheduler
VERSION=noop
ENVIRONMENT=test
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
ENVIRONMENT=prod
elif [[ $GITHUB_REF == refs/heads/main ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
MINOR=${VERSION%.*}
MAJOR=${MINOR%.*}
TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest"
elif [ "${{ github.event_name }}" = "push" ]; then
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
fi
echo ::set-output name=environment::${ENVIRONMENT}
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Docker values debug
run: |
echo ${{ steps.docker-prep.outputs.environment }}
echo ${{ steps.docker-prep.outputs.version }}
echo ${{ steps.docker-prep.outputs.tags }}
echo ${{ steps.docker-prep.outputs.created }}

.NET8 has this stuff built in

See: https://laurentkempe.com/2023/10/30/publish-dotnet-docker-images-using-dotnet-sdk-and-github-actions/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions