forked from e-mission/e-mission-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mahadik, Mukul Chandrakant
authored and
Mahadik, Mukul Chandrakant
committed
Sep 28, 2024
1 parent
1f0ec98
commit a408130
Showing
2 changed files
with
68 additions
and
24 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,15 @@ jobs: | |
repository: MukuFlash03/${{ inputs.repo }} | ||
ref: ${{ inputs.branch }} | ||
token: ${{ secrets.GH_FG_PAT_TAGS }} | ||
|
||
- name: Fetch server image tag | ||
id: get-server-tag | ||
run: | | ||
if [ "${{ inputs.repo }}" = "op-admin-dashboard" ] || [ "${{ inputs.repo }}" = "em-public-dashboard" ]; then | ||
response=$(curl -s https://raw.githubusercontent.com/MukuFlash03/e-mission-server/refs/heads/cleanup-cicd/.env) | ||
SERVER_IMAGE_TAG=$(echo "$response" | grep "SERVER_IMAGE_TAG=" | cut -d'=' -f2) | ||
echo "SERVER_IMAGE_TAG=$SERVER_IMAGE_TAG" >> "$GITHUB_OUTPUT" | ||
fi | ||
- name: Set docker image tags | ||
id: set-tags | ||
|
@@ -32,7 +41,25 @@ jobs: | |
set -a; source .env; set +a | ||
if [ "${{ inputs.repo }}" = "nrel-openpath-join-page" ]; then | ||
echo "JOIN_IMAGE_TAG=${JOIN_IMAGE_TAG}" >> "$GITHUB_OUTPUT" | ||
echo "Current join-page image tag (push): ${JOIN_IMAGE_TAG}" | ||
elif [ "${{ inputs.repo }}" = "op-admin-dashboard" ]; then | ||
echo "ADMIN_DASH_IMAGE_TAG=${ADMIN_DASH_IMAGE_TAG}" >> "$GITHUB_OUTPUT" | ||
elif [ "${{ inputs.repo }}" = "em-public-dashboard" ]; then | ||
echo "PUBLIC_DASH_NOTEBOOK_IMAGE_TAG=${PUBLIC_DASH_NOTEBOOK_IMAGE_TAG}" >> "$GITHUB_OUTPUT" | ||
echo "PUBLIC_DASH_FRONTEND_IMAGE_TAG=${PUBLIC_DASH_FRONTEND_IMAGE_TAG}" >> "$GITHUB_OUTPUT" | ||
fi | ||
- name: Print input docker image tags | ||
run: | | ||
echo "Event name: ${{ github.event_name }}" | ||
if [ "${{ inputs.repo }}" = "nrel-openpath-join-page" ]; then | ||
echo "Current join-page image tag: ${{ steps.set-tags.outputs.JOIN_IMAGE_TAG }}" | ||
elif [ "${{ inputs.repo }}" = "op-admin-dashboard" ]; then | ||
echo "Current admin-dash image tag: ${{ steps.set-tags.outputs.ADMIN_DASH_IMAGE_TAG }}" | ||
echo "Latest server image tag (${{ github.event_name }}): ${{ steps.get-server-tag.outputs.SERVER_IMAGE_TAG }}" | ||
elif [ "${{ inputs.repo }}" = "em-public-dashboard" ]; then | ||
echo "Current notebook image tag (push): ${{ steps.set-tags.outputs.PUBLIC_DASH_NOTEBOOK_IMAGE_TAG }}" | ||
echo "Current frontend image tag (push): ${{ steps.set-tags.outputs.PUBLIC_DASH_FRONTEND_IMAGE_TAG }}" | ||
echo "Latest server image tag (${{ github.event_name }}): ${{ steps.get-server-tag.outputs.SERVER_IMAGE_TAG }}" | ||
fi | ||
- name: docker login | ||
|
@@ -49,38 +76,56 @@ jobs: | |
- name: build docker image | ||
run: | | ||
if [ "${{ inputs.repo }}" = "nrel-openpath-join-page" ]; then | ||
# docker build -t $DOCKER_USER/${{ inputs.repo }}:${{ inputs.branch }}_${{ steps.date.outputs.date }} ./frontend | ||
docker build -t $DOCKER_USER/${{ inputs.repo }}:${{ inputs.branch }}_${{ steps.date.outputs.date }} ./frontend | ||
elif [ "${{ inputs.repo }}" = "op-admin-dashboard" ]; then | ||
SERVER_IMAGE_TAG=${{ steps.get-server-tag.outputs.SERVER_IMAGE_TAG }} docker compose -f docker-compose-prod.yml build | ||
elif [ "${{ inputs.repo }}" = "em-public-dashboard" ]; then | ||
SERVER_IMAGE_TAG=${{ steps.get-server-tag.outputs.SERVER_IMAGE_TAG }} docker compose -f docker-compose.yml build | ||
fi | ||
docker images | ||
- name: rename docker image | ||
run: | | ||
if [ "${{ inputs.repo }}" = "op-admin-dashboard" ]; then | ||
docker image tag e-mission/opdash:0.0.1 $DOCKER_USER/${{ inputs.repo }}:${{ inputs.branch }}_${{ steps.date.outputs.date }} | ||
elif [ "${{ inputs.repo }}" = "em-public-dashboard" ]; then | ||
if [ "${{ github.event_name }}" == "push" ]; then | ||
docker image tag em-pub-dash-prod/frontend:latest $DOCKER_USER/${{ inputs.repo }}_frontend:${{ inputs.branch }}_${{ steps.date.outputs.date }} | ||
fi | ||
docker image tag em-pub-dash-prod/viz-scripts:latest $DOCKER_USER/${{ inputs.repo }}_notebook:${{ inputs.branch }}_${{ steps.date.outputs.date }} | ||
fi | ||
- name: push docker image | ||
run: | | ||
# docker push $DOCKER_USER/${{ inputs.repo }}:${{ inputs.branch }}_${{ steps.date.outputs.date }} | ||
docker push $DOCKER_USER/${{ inputs.repo }}:${{ inputs.branch }}_${{ steps.date.outputs.date }} | ||
if [ "${{ inputs.repo }}" = "op-admin-dashboard" ] || [ "${{ inputs.repo }}" = "nrel-openpath-join-page" ]; then | ||
docker push $DOCKER_USER/${{ inputs.repo }}:${{ inputs.branch }}_${{ steps.date.outputs.date }} | ||
elif [ "${{ inputs.repo }}" = "em-public-dashboard" ]; then | ||
if [ "${{ github.event_name }}" == "push" ]; then | ||
docker push $DOCKER_USER/${{ inputs.repo }}_frontend:${{ inputs.branch }}_${{ steps.date.outputs.date }} | ||
fi | ||
docker push $DOCKER_USER/${{ inputs.repo }}_notebook:${{ inputs.branch }}_${{ steps.date.outputs.date }} | ||
fi | ||
- name: Update .env file | ||
run: | | ||
if [ "${{ inputs.repo }}" = "nrel-openpath-join-page" ]; then | ||
echo "JOIN_IMAGE_TAG=${{ inputs.branch }}_${{ steps.date.outputs.date }}" > .env | ||
# elif [ "${{ inputs.repo }}" = "op-admin-dashboard" ]; then | ||
# echo "SERVER_IMAGE_TAG=${{ steps.get-server-tag.outputs.SERVER_IMAGE_TAG }}" >> .env | ||
# echo "ADMIN_DASH_IMAGE_TAG=${{ inputs.branch }}_${{ steps.date.outputs.date }}" > .env | ||
# elif [ "${{ inputs.repo }}" = "em-public-dashboard" ]; then | ||
# echo "PUBLIC_DASH_NOTEBOOK_IMAGE_TAG=${{ inputs.branch }}_${{ steps.date.outputs.date }}" > .env | ||
# if [ "${{ github.event_name }}" == "workflow_call" ]; then | ||
# echo "Workflow_call: Reuse existing frontend image tag" | ||
# echo "PUBLIC_DASH_FRONTEND_IMAGE_TAG=${{ steps.set-tags.outputs.PUBLIC_DASH_FRONTEND_IMAGE_TAG }}" >> .env | ||
# else | ||
# echo "Push event: Update frontend image tag" | ||
# echo "PUBLIC_DASH_FRONTEND_IMAGE_TAG=${{ inputs.branch }}_${{ steps.date.outputs.date }}" >> .env | ||
# fi | ||
# echo "SERVER_IMAGE_TAG=${{ steps.get-server-tag.outputs.SERVER_IMAGE_TAG }}" >> .env | ||
# echo "PUBLIC_DASHBOARD_IMAGE_TAG=${{ inputs.branch }}_${{ steps.date.outputs.date }}" > .env | ||
elif [ "${{ inputs.repo }}" = "op-admin-dashboard" ]; then | ||
echo "ADMIN_DASH_IMAGE_TAG=${{ inputs.branch }}_${{ steps.date.outputs.date }}" > .env | ||
echo "SERVER_IMAGE_TAG=${{ steps.get-server-tag.outputs.SERVER_IMAGE_TAG }}" >> .env | ||
elif [ "${{ inputs.repo }}" = "em-public-dashboard" ]; then | ||
echo "PUBLIC_DASH_NOTEBOOK_IMAGE_TAG=${{ inputs.branch }}_${{ steps.date.outputs.date }}" > .env | ||
if [ "${{ github.event_name }}" == "push" ]; then | ||
echo "Push event: Update frontend image tag" | ||
echo "PUBLIC_DASH_FRONTEND_IMAGE_TAG=${{ inputs.branch }}_${{ steps.date.outputs.date }}" >> .env | ||
else | ||
echo "Workflow_call: Reuse existing frontend image tag" | ||
echo "PUBLIC_DASH_FRONTEND_IMAGE_TAG=${{ steps.set-tags.outputs.PUBLIC_DASH_FRONTEND_IMAGE_TAG }}" >> .env | ||
fi | ||
echo "SERVER_IMAGE_TAG=${{ steps.get-server-tag.outputs.SERVER_IMAGE_TAG }}" >> .env | ||
fi | ||
cat .env | ||
- name: Add, Commit, Push changes to .env file | ||
run: | | ||
git config --local user.email "[email protected]" | ||
|
@@ -90,7 +135,6 @@ jobs: | |
else | ||
git add .env | ||
git commit -m "Updated docker image tags in .env file to the latest timestamp" | ||
# git push https://${{ secrets.GH_FG_PAT_TAGS }}@github.com/MukuFlash03/${{ inputs.repo }}.git HEAD:${{ inputs.branch }} | ||
git push origin | ||
fi | ||
cat .env |