Merge pull request #60 from MarShaikh/Solves-script/db_create-fails-#59 #242
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: Web UI-Build, Test & Publish Docker | |
on: | |
push: | |
env: | |
IMAGE_NAME: web-ui | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set variables | |
id: variables | |
run: | | |
IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME | |
# Change all uppercase to lowercase | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
# Strip git ref prefix (refs/heads/ or refs/tags/) from version | |
# but keep the rest of the ref. Replaces / with - to make the package name valid. | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,refs/\(heads\|tags\)/\(.*\),\2,' | tr '/' '-') | |
# Strip "refs/tags/v" prefix from tag name | |
[[ "${GITHUB_REF}" == "refs/tags/"* ]] && VERSION=$(echo "${GITHUB_REF}" | sed -e 's:^refs/tags/v::') | |
# Always tag with git sha or version tag | |
echo IMAGE_ID=$IMAGE_ID | |
echo "::set-output name=image_id::$IMAGE_ID" | |
echo VERSION=$VERSION | |
echo "::set-output name=version::$VERSION" | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Run tests | |
run: docker-compose build test | |
- name: Build image | |
run: docker-compose build release | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push image | |
run: | | |
IMAGE_ID=${{ steps.variables.outputs.image_id }} | |
VERSION=${{ steps.variables.outputs.version }} | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
docker tag image $IMAGE_ID:$VERSION | |
docker push $IMAGE_ID:$VERSION | |
- name: Push image (latest) | |
if: ${{ github.ref_name == 'main' }} | |
run: | | |
IMAGE_ID=${{ steps.variables.outputs.image_id }} | |
VERSION=latest | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
docker tag image $IMAGE_ID:$VERSION | |
docker push $IMAGE_ID:$VERSION | |
- name: Apply staging configuration | |
run: cp -r .override-staging/ .override/ | |
- name: Build image | |
run: docker-compose build release | |
- name: Push image (staging) | |
run: | | |
IMAGE_ID=${{ steps.variables.outputs.image_id }} | |
VERSION=${{ steps.variables.outputs.version }}-staging | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
docker tag image $IMAGE_ID:$VERSION | |
docker push $IMAGE_ID:$VERSION |