Skip to content

Commit

Permalink
Artifact + Matrix - 5
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.

Had to remove .env from the .gitignore file.
  • Loading branch information
Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed May 3, 2024
1 parent 58093d3 commit 368900b
Show file tree
Hide file tree
Showing 5 changed files with 21 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 "[email protected]"
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ celerybeat.pid
*.sage.py

# Environments
.env
.venv
env/
venv/
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
context: viz_scripts
dockerfile: docker/Dockerfile.dev
args:
DOCKER_IMAGE_TAG: ''
DOCKER_IMAGE_TAG: ${DOCKER_IMAGE_TAG}
depends_on:
- db
environment:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ services:
context: viz_scripts
dockerfile: Dockerfile
args:
DOCKER_IMAGE_TAG: ''
DOCKER_IMAGE_TAG: ${DOCKER_IMAGE_TAG}
depends_on:
- db
environment:
Expand Down

0 comments on commit 368900b

Please sign in to comment.