Skip to content

Commit 368900b

Browse files
Mahadik, Mukul ChandrakantMahadik, Mukul Chandrakant
authored andcommitted
Artifact + Matrix - 5
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. Had to remove .env from the .gitignore file.
1 parent 58093d3 commit 368900b

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DOCKER_IMAGE_TAG=2024-05-02--16-40

.github/workflows/image_build_push.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,24 @@ jobs:
118118
echo "Latest docker image tag (push): ${{ env.DOCKER_IMAGE_TAG_1 }}"
119119
echo "Latest docker image tag (workflow_dispatch): ${{ env.DOCKER_IMAGE_TAG_2 }}"
120120
121+
- name: Update .env file
122+
run: |
123+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
124+
echo "Workflow_dispatch: New server image built and pushed, Updating image tag in .env"
125+
echo "DOCKER_IMAGE_TAG=$DOCKER_IMAGE_TAG_2" > .env
126+
else
127+
echo "Push event: Restoring latest server image tag in .env"
128+
echo "DOCKER_IMAGE_TAG=$DOCKER_IMAGE_TAG_1" > .env
129+
fi
130+
131+
- name: Add, Commit, Push changes to .env file
132+
run: |
133+
git config --local user.email "action@github.com"
134+
git config --local user.name "GitHub Action"
135+
git add .env
136+
git commit -m "Updated docker image tag in .env to the latest timestamp: ${{ env.DOCKER_IMAGE_TAG_2 }}"
137+
git push origin
138+
121139
- name: docker login
122140
run: | # log into docker hub account
123141
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ celerybeat.pid
108108
*.sage.py
109109

110110
# Environments
111-
.env
112111
.venv
113112
env/
114113
venv/

docker-compose.dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ services:
2121
context: viz_scripts
2222
dockerfile: docker/Dockerfile.dev
2323
args:
24-
DOCKER_IMAGE_TAG: ''
24+
DOCKER_IMAGE_TAG: ${DOCKER_IMAGE_TAG}
2525
depends_on:
2626
- db
2727
environment:

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ services:
2020
context: viz_scripts
2121
dockerfile: Dockerfile
2222
args:
23-
DOCKER_IMAGE_TAG: ''
23+
DOCKER_IMAGE_TAG: ${DOCKER_IMAGE_TAG}
2424
depends_on:
2525
- db
2626
environment:

0 commit comments

Comments
 (0)