Publish and deploy image #6
Workflow file for this run
This file contains hidden or 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: Publish and deploy dev image | |
on: | |
push: | |
tags: | |
- '!**' | |
workflow_dispatch: | |
env: | |
REGISTRY_URL: ${{ secrets.HARBOR_URL }} | |
jobs: | |
build-push: | |
runs-on: gha-runners-smartweb | |
strategy: | |
matrix: | |
include: | |
- dockerfile: Dockerfile.backend | |
image_name: web/appquiz-backend | |
- dockerfile: Dockerfile.frontend | |
image_name: web/appquiz-frontend | |
steps: | |
- name: Build tags | |
run: | | |
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7) | |
{ | |
echo 'IMAGE_TAGS<<EOF' | |
echo '${{ env.REGISTRY_URL }}/${{ matrix.image_name }}:latest' | |
echo '${{ env.REGISTRY_URL }}/${{ matrix.image_name }}:'$SHORT_SHA | |
echo EOF | |
} >> $GITHUB_ENV | |
- name: Build push and notify | |
uses: IMIO/gha/build-push-notify@precommand_buildpush | |
with: | |
DOCKERFILE: ${{ matrix.dockerfile }} | |
IMAGE_NAME: ${{ matrix.image_name }} | |
IMAGE_TAGS: ${{ env.IMAGE_TAGS }} | |
REGISTRY_URL: ${{ env.REGISTRY_URL}} | |
REGISTRY_USERNAME: ${{ secrets.SMARTWEB_HARBOR_USERNAME }} | |
REGISTRY_PASSWORD: ${{ secrets.SMARTWEB_HARBOR_PASSWORD }} | |
PRE_BUILD_COMMANDS: | | |
echo "Setting up production environment" | |
sed -i "s|apiUrl: 'http://localhost:3000/api'|apiUrl: '${{ secrets.BACKEND_URL }}'|g" src/environments/environment.prod.ts | |
echo "Updated environment.prod.ts with BACKEND_URL: ${{ secrets.BACKEND_URL }}" |