-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39764fe
commit e04273c
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: Dockerize Experimental | ||
|
||
on: | ||
# This is for evaluation purposes | ||
workflow_dispatch: | ||
inputs: | ||
manual_trigger: | ||
description: 'Manual trigger' | ||
required: true | ||
default: 'true' | ||
# 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@v2 | ||
|
||
- name: Cache Docker layers | ||
uses: docker/buildx-cache-action@v2 | ||
with: | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache | ||
|
||
- 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 \ | ||
--cache-from type=local,src=/tmp/.buildx-cache \ | ||
--cache-to type=local,dest=/tmp/.buildx-cache \ | ||
--push \ | ||
--tag ${{ steps.prep.outputs.tags }} \ | ||
. |