From 455d4c01c5aeeab4c09621209345ebf73499d165 Mon Sep 17 00:00:00 2001 From: Jay Date: Mon, 8 Jan 2024 15:16:08 -0500 Subject: [PATCH] Naming of docker image action --- .github/workflows/docker-image.yml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index cb56431..d116444 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -9,7 +9,6 @@ on: types: [published] jobs: - backend-build: runs-on: ubuntu-latest steps: @@ -18,11 +17,14 @@ jobs: - name: Build and push the Docker image for backend run: | - TIMESTAMP=$(date +%s) - docker build ./backend -t themanwholikestocode/archive-me-prod:backend-$TIMESTAMP - docker tag themanwholikestocode/archive-me-prod:backend-$TIMESTAMP domain.com/repo/tag_docker_name:latest + if [ ${{ github.event_name }} == 'pull_request' ]; then + DOCKER_IMAGE_TAG=development + else + DOCKER_IMAGE_TAG=production + fi + docker build ./backend -t themanwholikestocode/archive-me-prod:backend-$DOCKER_IMAGE_TAG echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin - docker push themanwholikestocode/archive-me-prod:backend-$TIMESTAMP + docker push themanwholikestocode/archive-me-prod:backend-$DOCKER_IMAGE_TAG frontend-build: runs-on: ubuntu-latest @@ -32,8 +34,11 @@ jobs: - name: Build and push the Docker image for frontend run: | - TIMESTAMP=$(date +%s) - docker build ./frontend -t themanwholikestocode/archive-me-prod:frontend-$TIMESTAMP - docker tag themanwholikestocode/archive-me-prod:frontend-$TIMESTAMP domain.com/repo/tag_docker_name:latest + if [ ${{ github.event_name }} == 'pull_request' ]; then + DOCKER_IMAGE_TAG=development + else + DOCKER_IMAGE_TAG=production + fi + docker build ./frontend -t themanwholikestocode/archive-me-prod:frontend-$DOCKER_IMAGE_TAG echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin - docker push themanwholikestocode/archive-me-prod:frontend-$TIMESTAMP + docker push themanwholikestocode/archive-me-prod:frontend-$DOCKER_IMAGE_TAG