Update docker-image.yml #3
Workflow file for this run
This file contains 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: Dockerize Experimental | |
on: | |
push: | |
pull_request: | |
jobs: | |
dockerize: | |
runs-on: ubuntu-latest | |
# "push" event is not triggered for forks, so need to listen for | |
# pull_requests, but only for external ones, so as not to run the action | |
# twice | |
if: | |
github.event_name != 'pull_request' || | |
github.event.pull_request.head.repo.fork == true | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Prepare | |
id: prep | |
run: | | |
DOCKER_IMAGE=specifyconsortium/specify7-service | |
VERSION=noop | |
if [ "${{ github.event_name }}" = "schedule" ]; then | |
VERSION=nightly | |
elif [[ $GITHUB_REF == refs/tags/* ]]; then | |
VERSION=${GITHUB_REF#refs/tags/} | |
elif [[ $GITHUB_REF == refs/heads/* ]]; then | |
# Docker does not like / in tag names, so replace them with - | |
# See https://github.com/specify/specify7-test-panel/issues/110#issuecomment-1943045253 | |
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') | |
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then | |
VERSION=edge | |
fi | |
elif [[ $GITHUB_REF == refs/pull/* ]]; then | |
VERSION=pr-${{ github.event.number }} | |
fi | |
TAGS="${DOCKER_IMAGE}:${VERSION}" | |
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | |
HOTFIX=${VERSION%.*} | |
MINOR=${HOTFIX%.*} | |
MAJOR=${MINOR%.*} | |
TAGS="$TAGS,${DOCKER_IMAGE}:${HOTFIX},${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest" | |
elif [[ $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}" | |
fi | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
echo "tags=${TAGS}" >> $GITHUB_OUTPUT | |
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
version: 'latest' | |
platforms: 'linux/amd64,linux/arm64' | |
driver-opts: 'image=moby/buildkit:master' | |
buildkitd-flags: '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host' | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
run: | | |
docker buildx build --platform linux/amd64,linux/arm64 \ | |
--push \ | |
--tag ${{ steps.prep.outputs.tags }} \ | |
. |