Skip to content

Commit

Permalink
Artifact + Matrix - 9
Browse files Browse the repository at this point in the history
Adding .env file which stores only docker image timestamp for the latest dockerhub e-mission-server image already pushed.

.env file overwritten in both types of trigger events - push and workflow_dispatch.

Added commit and push github actions as well for pushing latest changes to the .env file made via the workflow.

Lastly, docker-compose now also mentions the ENV variable name to be read from the .env file for the ARG value in the Dockerfile.

No changes required in the Dockerfiles.
  • Loading branch information
Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed May 3, 2024
1 parent 0c78ad3 commit d03ce01
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DOCKER_IMAGE_TAG=2024-05-02--16-40
18 changes: 18 additions & 0 deletions .github/workflows/image_build_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,24 @@ jobs:
echo "Latest docker image tag (push): ${{ env.DOCKER_IMAGE_TAG_1 }}"
echo "Latest docker image tag (workflow_dispatch): ${{ env.DOCKER_IMAGE_TAG_2 }}"
- name: Update .env file
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "Workflow_dispatch: New server image built and pushed, Updating image tag in .env"
echo "DOCKER_IMAGE_TAG=$DOCKER_IMAGE_TAG_2" > .env
else
echo "Push event: Restoring latest server image tag in .env"
echo "DOCKER_IMAGE_TAG=$DOCKER_IMAGE_TAG_1" > .env
fi
- name: Add, Commit, Push changes to .env file
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .env
git commit -m "Updated docker image tag in .env to the latest timestamp: ${{ env.DOCKER_IMAGE_TAG_2 }}"
git push origin
- name: docker login
run: | # log into docker hub account
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
context: .
dockerfile: docker/Dockerfile
args:
DOCKER_IMAGE_TAG: ''
DOCKER_IMAGE_TAG: ${DOCKER_IMAGE_TAG}
image: e-mission/opdash:0.0.1
ports:
- "8050:8050"
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-prod-nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
context: .
dockerfile: docker/Dockerfile
args:
DOCKER_IMAGE_TAG: ''
DOCKER_IMAGE_TAG: ${DOCKER_IMAGE_TAG}
image: e-mission/opdash:0.0.1
environment:
DASH_DEBUG_MODE: "True"
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
context: .
dockerfile: docker/Dockerfile
args:
DOCKER_IMAGE_TAG: ''
DOCKER_IMAGE_TAG: ${DOCKER_IMAGE_TAG}
image: e-mission/opdash:0.0.1
ports:
- "8050:8050"
Expand Down

0 comments on commit d03ce01

Please sign in to comment.