Skip to content

Config update for project-factory #1629

Config update for project-factory

Config update for project-factory #1629

name: project factory service docker Image CI
on:
push:
branches: [ "campaign" ]
paths:
- 'utilities/project-factory/**'
pull_request:
branches: [ "campaign" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for tags and branches
- name: Set up environment variables
id: env
run: |
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "ACTION_NUMBER=${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
echo "COMMIT_ID=${GITHUB_SHA: -8}" >> $GITHUB_ENV # Extract last 8 characters of SHA
- name: Build the service Docker image
id: docker_build
working-directory: ./utilities/project-factory
run: |
IMAGE_TAG=egovio/project-factory:${{ env.BRANCH_NAME }}-${{ env.COMMIT_ID }}-${{ env.ACTION_NUMBER }}
docker build . \
--file Dockerfile \
--tag $IMAGE_TAG
echo "::set-output name=image_name::$IMAGE_TAG"
- name: Build the db migration Docker image
id: docker_db_build
working-directory: ./utilities/project-factory/migration
run: |
IMAGE_TAG=egovio/project-factory-db:${{ env.BRANCH_NAME }}-${{ env.COMMIT_ID }}-${{ env.ACTION_NUMBER }}
docker build . \
--file Dockerfile \
--tag $IMAGE_TAG
echo "::set-output name=db_image_name::$IMAGE_TAG"
- name: Login to Docker Hub and Push Docker Image
working-directory: ./utilities/project-factory
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
IMAGE_NAME: ${{ steps.docker_build.outputs.image_name }}
run: |
# Authenticate with Docker Hub
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
# Push the image to Docker Hub
docker push $IMAGE_NAME
echo "Docker image pushed: $IMAGE_NAME"
- name: Login to Docker Hub and Push DB Migration Docker Image
working-directory: ./utilities/project-factory/migration
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DB_IMAGE_NAME: ${{ steps.docker_db_build.outputs.db_image_name }}
run: |
# Authenticate with Docker Hub
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
# Push the image to Docker Hub
docker push $DB_IMAGE_NAME
echo "Docker image pushed: $DB_IMAGE_NAME"