Merge pull request #60 from vlizBE/dependabot/pip/services/content-un… #67
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: Docker Images Build & Push to ghrc.io | |
on: | |
push: | |
branches: ["main"] | |
tags: ["v*.*.*"] | |
pull_request: | |
branches: ["main"] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the codebase | |
uses: actions/checkout@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build the Docker images and Push them to the registry-namespace indicated in REG_NS | |
run: | | |
touch .env # make sure we have one to satisfy the build | |
export REG_NS="ghcr.io/vlizbe/vocabserver-app" # sets the public scope for these, no uppercases are allowed | |
TAG_NAME=${GITHUB_REF#refs/tags/} # this is the tag name of the release | |
echo $TAG_NAME # this is the tag name of the release | |
# build tag is the same as tag name for releases if this matches the semver format else it is latest | |
# The string you want to check | |
# The regular expression | |
regex="^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\\+([0-9a-zA-Z-]+(\\.[0-9a-zA-Z-]+)*))?$" | |
if [[ $TAG_NAME =~ $regex ]]; then | |
export BUILD_TAG=$TAG_NAME | |
else | |
export BUILD_TAG="latest" | |
fi | |
echo $BUILD_TAG | |
DIMGS="content-unification vocab-configs vocab-fetch" | |
cd services | |
for dimg in $DIMGS; do | |
echo "Building $REG_NS/$dimg:$BUILD_TAG" | |
docker build -t $REG_NS/$dimg:$BUILD_TAG -f $dimg/Dockerfile . | |
docker push $REG_NS/$dimg:$BUILD_TAG | |
done |