From 87e3e0df8d230ab2e19be641efeffa91c0ebd111 Mon Sep 17 00:00:00 2001 From: nbarrett Date: Mon, 2 Sep 2024 08:29:58 +0100 Subject: [PATCH] - move all docker build steps to single workflow --- ...y-ngx-ramblers-docker-image-via-heroku.yml | 19 ++++++++++--------- ...h-and-deploy-ngx-ramblers-docker-image.yml | 5 ----- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-push-and-deploy-ngx-ramblers-docker-image-via-heroku.yml b/.github/workflows/build-push-and-deploy-ngx-ramblers-docker-image-via-heroku.yml index 7e546d0..56f4ef1 100644 --- a/.github/workflows/build-push-and-deploy-ngx-ramblers-docker-image-via-heroku.yml +++ b/.github/workflows/build-push-and-deploy-ngx-ramblers-docker-image-via-heroku.yml @@ -1,4 +1,4 @@ -name: Deploy Docker image to Heroku +name: Deploy and Build Docker Image and release to Heroku on: push: @@ -13,29 +13,30 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v3 - + - name: Log in to Docker Hub + run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin + - name: Build the Docker image + run: | + docker build . --file Dockerfile --tag ngx-ramblers:latest + - name: Tag the Docker image + run: docker tag ngx-ramblers:latest ${{ secrets.DOCKER_USERNAME }}/ngx-ramblers:latest + - name: Push the Docker image to Docker Hub + run: docker push ${{ secrets.DOCKER_USERNAME }}/ngx-ramblers:latest - name: Install Heroku CLI run: | curl https://cli-assets.heroku.com/install.sh | sh - - name: Log in to Heroku container registry run: | echo "${{ secrets.HEROKU_API_KEY }}" | docker login --username="${{ secrets.HEROKU_EMAIL }}" --password-stdin registry.heroku.com - - name: Pull Docker image from Docker Hub run: | docker pull nbarrett36/ngx-ramblers:latest - - name: Tag Docker image for Heroku run: | docker tag nbarrett36/ngx-ramblers:latest registry.heroku.com/ngx-ramblers-docker/web - - name: Push Docker image to Heroku run: | docker push registry.heroku.com/ngx-ramblers-docker/web - - name: Release Docker image on Heroku run: | heroku container:release web --app ngx-ramblers-docker - env: - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} diff --git a/.github/workflows/build-push-and-deploy-ngx-ramblers-docker-image.yml b/.github/workflows/build-push-and-deploy-ngx-ramblers-docker-image.yml index 455dcf6..f462f09 100644 --- a/.github/workflows/build-push-and-deploy-ngx-ramblers-docker-image.yml +++ b/.github/workflows/build-push-and-deploy-ngx-ramblers-docker-image.yml @@ -1,11 +1,6 @@ name: Build and Deploy NGX-Ramblers Docker Image on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - jobs: build: runs-on: ubuntu-latest