Skip to content

chore: Update Docker image build and push paths for services in docke… #39

chore: Update Docker image build and push paths for services in docke…

chore: Update Docker image build and push paths for services in docke… #39

Workflow file for this run

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: install jq
run: sudo apt-get install jq
- name: Extract all existing tags for the repo
id: get_tags
run: |
echo "::set-output name=tags::$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/tags | jq -r '.[].name')"
- name: Build docker images using sha of tags
run: |
echo ${{ steps.get_tags.outputs.tags }}
- 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