From 56d3acc625ac051b8fb9e049946a04ced1c1c293 Mon Sep 17 00:00:00 2001 From: RajNilkar <122857743+RajNilkar@users.noreply.github.com> Date: Mon, 24 Nov 2025 08:22:31 -0700 Subject: [PATCH 01/19] Add CI/CD pipeline for testing and Docker deployment Created a workflow for building and running two jobs based on project requirements in the rubric --- .github/workflows/deploy.yml | 51 ++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..ed893be --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,51 @@ +name: CI/CD Pipeline + +on: + push: + branches: [ "main" ] +env: + DOCKER_IMAGE: ${{ secrets.DOCKER_HUB_USERNAME }}/weather_planner_app + +jobs: + +#1) Test Job +test: + runs_on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/Checkout@v3 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - name: Install dependencies + run: | + pip install -r requirements.txt + pip install pytest + + - name: Run Tests + run: pytest + +#2) Build and Push to Docker Hub +build: + runs-on: ubuntu-latest + needs: test + + steps: + - name: Checkout Repository + uses: actions/Checkout@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Build Docker Image + run: docker build -t $DOCKER_IMAGE . + + - name: Push Image to Docker Hub + run: docker push $DOCKER_IMAGE From 89aad2ae11cd3b208b03bf52cc2de38b8d9f67e5 Mon Sep 17 00:00:00 2001 From: RajNilkar <122857743+RajNilkar@users.noreply.github.com> Date: Mon, 24 Nov 2025 09:09:03 -0700 Subject: [PATCH 02/19] Reorganize structure in yaml file There were some indentation errors in the yaml file, that caused the workflow in actions to fail. --- .github/workflows/deploy.yml | 82 ++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ed893be..03a6d1a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -8,44 +8,44 @@ env: jobs: -#1) Test Job -test: - runs_on: ubuntu-latest - - steps: - - name: Checkout Repository - uses: actions/Checkout@v3 - - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: "3.11" - - - name: Install dependencies - run: | - pip install -r requirements.txt - pip install pytest - - - name: Run Tests - run: pytest - -#2) Build and Push to Docker Hub -build: - runs-on: ubuntu-latest - needs: test - - steps: - - name: Checkout Repository - uses: actions/Checkout@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - - name: Build Docker Image - run: docker build -t $DOCKER_IMAGE . - - - name: Push Image to Docker Hub - run: docker push $DOCKER_IMAGE + #1) Test Job + test: + runs_on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/Checkout@v3 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - name: Install dependencies + run: | + pip install -r requirements.txt + pip install pytest + + - name: Run Tests + run: pytest + + #2) Build and Push to Docker Hub + build: + runs-on: ubuntu-latest + needs: test + + steps: + - name: Checkout Repository + uses: actions/Checkout@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Build Docker Image + run: docker build -t $DOCKER_IMAGE . + + - name: Push Image to Docker Hub + run: docker push $DOCKER_IMAGE From 76f9a7fc489c28c4bebac9de22cbb062540f4b47 Mon Sep 17 00:00:00 2001 From: RajNilkar <122857743+RajNilkar@users.noreply.github.com> Date: Mon, 24 Nov 2025 09:10:30 -0700 Subject: [PATCH 03/19] Fix syntax for runs-on in deploy.yml --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 03a6d1a..83954ae 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,7 +10,7 @@ jobs: #1) Test Job test: - runs_on: ubuntu-latest + runs-on: ubuntu-latest steps: - name: Checkout Repository From b8f26c45f9a3261277c26c6f1035d02a37d09fdc Mon Sep 17 00:00:00 2001 From: RajNilkar <122857743+RajNilkar@users.noreply.github.com> Date: Mon, 24 Nov 2025 09:14:29 -0700 Subject: [PATCH 04/19] Update deploy.yml to trigger on all branches --- .github/workflows/deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 83954ae..0333f5a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,7 +2,8 @@ name: CI/CD Pipeline on: push: - branches: [ "main" ] + branches: + - "**" env: DOCKER_IMAGE: ${{ secrets.DOCKER_HUB_USERNAME }}/weather_planner_app From 7066500d344cf4d67c75ecb89cb7fcb909eae9d4 Mon Sep 17 00:00:00 2001 From: sethreec <112038379+sethreec@users.noreply.github.com> Date: Wed, 3 Dec 2025 00:29:57 -0700 Subject: [PATCH 05/19] Update deploy.yml testing update for deploy job in the .yaml --- .github/workflows/deploy.yml | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0333f5a..bdda608 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,21 +1,18 @@ name: CI/CD Pipeline - on: push: branches: - "**" env: - DOCKER_IMAGE: ${{ secrets.DOCKER_HUB_USERNAME }}/weather_planner_app - + DOCKER_IMAGE: ${{ secrets.DOCKER_HUB_USERNAME }}/weather_planner_app jobs: - #1) Test Job test: runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/Checkout@v3 + uses: actions/checkout@v3 - name: Setup Python uses: actions/setup-python@v4 @@ -37,16 +34,34 @@ jobs: steps: - name: Checkout Repository - uses: actions/Checkout@v3 + uses: actions/checkout@v3 - name: Login to Docker Hub uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - name: Build Docker Image - run: docker build -t $DOCKER_IMAGE . + run: docker build -t ${{ env.DOCKER_IMAGE }}:latest . - name: Push Image to Docker Hub - run: docker push $DOCKER_IMAGE + run: docker push ${{ env.DOCKER_IMAGE }}:latest + + #3) Deploy to AWS + deploy: + runs-on: ubuntu-latest + needs: build + + steps: + - name: Deploy Image + uses: appleboy/ssh-action@v1.2.4 + with: + host: ${{ secrets.AWS_ADDRESS }} + username: ${{ secrets.AWS_USERNAME }} + key: ${{ secrets.AWS_PEM }} + script: | + docker pull ${{ env.DOCKER_IMAGE }}:latest + docker stop weather_planner_app || true + docker rm weather_planner_app || true + docker run -d -e DOPPLER_TOKEN=${{ secrets.DOPPLER_TOKEN }} -p 8000:8000 --name weather_planner_app ${{ env.DOCKER_IMAGE }}:latest \ No newline at end of file From 600f4f538439a2d0f31db47b3e8752b6d4b0729b Mon Sep 17 00:00:00 2001 From: sethreec <112038379+sethreec@users.noreply.github.com> Date: Wed, 3 Dec 2025 00:47:12 -0700 Subject: [PATCH 06/19] Update deploy.yml made devtest environment to hold AWS secrets for testing --- .github/workflows/deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bdda608..48c6040 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,6 +31,7 @@ jobs: build: runs-on: ubuntu-latest needs: test + environment: devtest steps: - name: Checkout Repository From c9f1637cbf81188b5b8a4607f8945c900bcdc07c Mon Sep 17 00:00:00 2001 From: sethreec <112038379+sethreec@users.noreply.github.com> Date: Wed, 3 Dec 2025 00:50:32 -0700 Subject: [PATCH 07/19] Update deploy.yml changed wrong job to devtest environment. corrected --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 48c6040..c33dc19 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,7 +31,6 @@ jobs: build: runs-on: ubuntu-latest needs: test - environment: devtest steps: - name: Checkout Repository @@ -53,6 +52,7 @@ jobs: deploy: runs-on: ubuntu-latest needs: build + environment: devtest steps: - name: Deploy Image From bde404e8bda04a44791ac7929f2a396a9bb08197 Mon Sep 17 00:00:00 2001 From: sethreec <112038379+sethreec@users.noreply.github.com> Date: Wed, 3 Dec 2025 01:34:03 -0700 Subject: [PATCH 08/19] Update deploy.yml had error with docker not being installed on the aws server. got instructions on how to install docker on ubuntu from docker website and included in script changed 8000:8000 to 80:8000 to match online examples, will need reexamined included command to stop docker after successfully running the container because I don't understand AWS and am worried about racking up a bill, but this will have to be removed before the aws deployment is functional --- .github/workflows/deploy.yml | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c33dc19..911b0d8 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -62,7 +62,31 @@ jobs: username: ${{ secrets.AWS_USERNAME }} key: ${{ secrets.AWS_PEM }} script: | + sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc podman-docker containerd runc | cut -f1) + + sudo apt update + sudo apt install ca-certificates curl + sudo install -m 0755 -d /etc/apt/keyrings + sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc + + sudo chmod a+r /etc/apt/keyrings/docker.asc + sudo tee /etc/apt/sources.list.d/docker.sources < Date: Wed, 3 Dec 2025 01:37:23 -0700 Subject: [PATCH 09/19] Update deploy.yml I guess all docker commands must be sudo? Seems sketchy. --- .github/workflows/deploy.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 911b0d8..ba95040 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -84,9 +84,9 @@ jobs: sudo systemctl start docker - docker pull ${{ env.DOCKER_IMAGE }}:latest - docker stop weather_planner_app || true - docker rm weather_planner_app || true - docker run -d -e DOPPLER_TOKEN=${{ secrets.DOPPLER_TOKEN }} -p 80:8000 --name weather_planner_app ${{ env.DOCKER_IMAGE }}:latest + sudo docker pull ${{ env.DOCKER_IMAGE }}:latest + sudo docker stop weather_planner_app || true + sudo docker rm weather_planner_app || true + sudo docker run -d -e DOPPLER_TOKEN=${{ secrets.DOPPLER_TOKEN }} -p 80:8000 --name weather_planner_app ${{ env.DOCKER_IMAGE }}:latest sudo systemctl stop docker \ No newline at end of file From 64f1f3e91579972c0924b55055a08026f7168b90 Mon Sep 17 00:00:00 2001 From: sethreec <112038379+sethreec@users.noreply.github.com> Date: Wed, 3 Dec 2025 01:48:17 -0700 Subject: [PATCH 10/19] Update deploy.yml docker was not installing correctly, so trying this alternative and much simpler command using apt-get instead of apt --- .github/workflows/deploy.yml | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ba95040..3981f86 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -62,25 +62,9 @@ jobs: username: ${{ secrets.AWS_USERNAME }} key: ${{ secrets.AWS_PEM }} script: | - sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc podman-docker containerd runc | cut -f1) - sudo apt update - sudo apt install ca-certificates curl - sudo install -m 0755 -d /etc/apt/keyrings - sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc - - sudo chmod a+r /etc/apt/keyrings/docker.asc - sudo tee /etc/apt/sources.list.d/docker.sources < Date: Wed, 3 Dec 2025 02:00:31 -0700 Subject: [PATCH 11/19] Update deploy.yml updated logic to stop and then remove all docker containers before pulling and running the updated image --- .github/workflows/deploy.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3981f86..c75f368 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -68,9 +68,12 @@ jobs: sudo systemctl start docker + sudo docker stop $(docker ps -q) + sudo docker rm $(docker ps -aq) + sudo docker pull ${{ env.DOCKER_IMAGE }}:latest - sudo docker stop weather_planner_app || true - sudo docker rm weather_planner_app || true + sudo docker run -d -e DOPPLER_TOKEN=${{ secrets.DOPPLER_TOKEN }} -p 80:8000 --name weather_planner_app ${{ env.DOCKER_IMAGE }}:latest - sudo systemctl stop docker \ No newline at end of file + sudo systemctl stop docker + sudo systemctl stop docker.socket \ No newline at end of file From ccc36e721d8639bf98c276f935854c63fae8eed9 Mon Sep 17 00:00:00 2001 From: sethreec <112038379+sethreec@users.noreply.github.com> Date: Wed, 3 Dec 2025 02:29:08 -0700 Subject: [PATCH 12/19] Update deploy.yml changed cleanup logic to stop the running weather_planner_app container, remove the container, and then remove the old image before pulling the newest --- .github/workflows/deploy.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c75f368..b7cc601 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -68,8 +68,9 @@ jobs: sudo systemctl start docker - sudo docker stop $(docker ps -q) - sudo docker rm $(docker ps -aq) + sudo docker stop weather_planner_app + sudo docker rm weather_planner_app + sudo docker rmi ${{ env.DOCKER_IMAGE }} sudo docker pull ${{ env.DOCKER_IMAGE }}:latest From f5e721958054440db31562fc22d5768da584de24 Mon Sep 17 00:00:00 2001 From: sethreec <112038379+sethreec@users.noreply.github.com> Date: Wed, 3 Dec 2025 02:34:49 -0700 Subject: [PATCH 13/19] Update deploy.yml added || True statements to the cleanup logic to avoid breaking the script if the container/images are not there --- .github/workflows/deploy.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b7cc601..842ca9d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -68,9 +68,9 @@ jobs: sudo systemctl start docker - sudo docker stop weather_planner_app - sudo docker rm weather_planner_app - sudo docker rmi ${{ env.DOCKER_IMAGE }} + sudo docker stop weather_planner_app || True + sudo docker rm weather_planner_app || True + sudo docker rmi ${{ env.DOCKER_IMAGE }} || True sudo docker pull ${{ env.DOCKER_IMAGE }}:latest From 0879bb1e558404f90373c053c048cb71fe736c74 Mon Sep 17 00:00:00 2001 From: sethreec <112038379+sethreec@users.noreply.github.com> Date: Wed, 3 Dec 2025 20:31:43 -0700 Subject: [PATCH 14/19] Update deploy.yml testing improvement in deployment with a seperate job to set up the server --- .github/workflows/deploy.yml | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 842ca9d..31168c6 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -47,11 +47,34 @@ jobs: - name: Push Image to Docker Hub run: docker push ${{ env.DOCKER_IMAGE }}:latest - + + #?) Checks if server has Docker installed, and installs it if not + setupserver: + runs-on: ubuntu-latest + environment: devtest + + steps: + - name: Set Up Server + uses: appleboy/ssh-action@v1.2.4 + with: + host: ${{ secrets.AWS_ADDRESS }} + username: ${{ secrets.AWS_USERNAME }} + key: ${{ secrets.AWS_PEM }} + script: | + + if [[ $(which docker) && $(docker --version) ]]; then + echo "Docker Installed" + sudo docker --version + else + sudo apt-get update -y + sudo apt-get install docker.io -y + fi + + #3) Deploy to AWS deploy: runs-on: ubuntu-latest - needs: build + needs: [build, setupserver] environment: devtest steps: @@ -63,9 +86,6 @@ jobs: key: ${{ secrets.AWS_PEM }} script: | - sudo apt-get update -y - sudo apt-get install docker.io -y - sudo systemctl start docker sudo docker stop weather_planner_app || True @@ -76,5 +96,5 @@ jobs: sudo docker run -d -e DOPPLER_TOKEN=${{ secrets.DOPPLER_TOKEN }} -p 80:8000 --name weather_planner_app ${{ env.DOCKER_IMAGE }}:latest - sudo systemctl stop docker - sudo systemctl stop docker.socket \ No newline at end of file + sudo docker ps + sudo docker images \ No newline at end of file From 6f3c856b7ee81a1666518db04839a9052282e2c8 Mon Sep 17 00:00:00 2001 From: sethreec <112038379+sethreec@users.noreply.github.com> Date: Thu, 4 Dec 2025 10:46:16 -0700 Subject: [PATCH 15/19] Update deploy.yml went back to -p 8000:8000 rather than 80:8000 --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 31168c6..d2974a3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -94,7 +94,7 @@ jobs: sudo docker pull ${{ env.DOCKER_IMAGE }}:latest - sudo docker run -d -e DOPPLER_TOKEN=${{ secrets.DOPPLER_TOKEN }} -p 80:8000 --name weather_planner_app ${{ env.DOCKER_IMAGE }}:latest + sudo docker run -d -e DOPPLER_TOKEN=${{ secrets.DOPPLER_TOKEN }} -p 8000:8000 --name weather_planner_app ${{ env.DOCKER_IMAGE }}:latest sudo docker ps sudo docker images \ No newline at end of file From 1f661f5e7b2e3e19c5d2dedbe2ccdf1f9acf5007 Mon Sep 17 00:00:00 2001 From: sethreec <112038379+sethreec@users.noreply.github.com> Date: Thu, 4 Dec 2025 11:25:37 -0700 Subject: [PATCH 16/19] Update deploy.yml port 80 --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 31168c6..48c7050 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -71,7 +71,7 @@ jobs: fi - #3) Deploy to AWS + #3) Deploy to AWS - trying to build docker container to speak to port 80? deploy: runs-on: ubuntu-latest needs: [build, setupserver] From 3954533457c1e563e24cd6d706fa79736e3f468e Mon Sep 17 00:00:00 2001 From: sethreec <112038379+sethreec@users.noreply.github.com> Date: Thu, 4 Dec 2025 11:48:28 -0700 Subject: [PATCH 17/19] Update deploy.yml added one line to see if we can verify with github actions that at least one endpoint is functional --- .github/workflows/deploy.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 48c7050..f065758 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -97,4 +97,7 @@ jobs: sudo docker run -d -e DOPPLER_TOKEN=${{ secrets.DOPPLER_TOKEN }} -p 80:8000 --name weather_planner_app ${{ env.DOCKER_IMAGE }}:latest sudo docker ps - sudo docker images \ No newline at end of file + sudo docker images + + - name: Verify Deployment + run: curl http://${{ secrets.AWS_ADDRESS }}:80/location?city=Boise \ No newline at end of file From ebd5c84d8b46d0069c828952cbffa0a92e1c1f3a Mon Sep 17 00:00:00 2001 From: sethreec <112038379+sethreec@users.noreply.github.com> Date: Thu, 4 Dec 2025 11:59:39 -0700 Subject: [PATCH 18/19] Update deploy.yml changed to port 80 --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d2974a3..31168c6 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -94,7 +94,7 @@ jobs: sudo docker pull ${{ env.DOCKER_IMAGE }}:latest - sudo docker run -d -e DOPPLER_TOKEN=${{ secrets.DOPPLER_TOKEN }} -p 8000:8000 --name weather_planner_app ${{ env.DOCKER_IMAGE }}:latest + sudo docker run -d -e DOPPLER_TOKEN=${{ secrets.DOPPLER_TOKEN }} -p 80:8000 --name weather_planner_app ${{ env.DOCKER_IMAGE }}:latest sudo docker ps sudo docker images \ No newline at end of file From d3ea08dc0b388a7d6e6bb6962f0dd391bab0de95 Mon Sep 17 00:00:00 2001 From: sethreec <112038379+sethreec@users.noreply.github.com> Date: Thu, 4 Dec 2025 13:03:04 -0700 Subject: [PATCH 19/19] Update deploy.yml creates a testdeploy job --- .github/workflows/deploy.yml | 52 ++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f065758..72935ca 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -88,9 +88,9 @@ jobs: sudo systemctl start docker - sudo docker stop weather_planner_app || True - sudo docker rm weather_planner_app || True - sudo docker rmi ${{ env.DOCKER_IMAGE }} || True + sudo docker stop weather_planner_app || true + sudo docker rm weather_planner_app || true + sudo docker rmi ${{ env.DOCKER_IMAGE }} || true sudo docker pull ${{ env.DOCKER_IMAGE }}:latest @@ -99,5 +99,47 @@ jobs: sudo docker ps sudo docker images - - name: Verify Deployment - run: curl http://${{ secrets.AWS_ADDRESS }}:80/location?city=Boise \ No newline at end of file + #4) Tests Deployment + testdeploy: + runs-on: ubuntu-latest + needs: deploy + environment: devtest + + steps: + + #Start by SSHing back into the AWS server and verifying that you can access the openapi schema from localhost + #This verifies that the container is running locally on the AWS server + + - name: Verify Container Running + uses: appleboy/ssh-action@v1.2.4 + with: + host: ${{ secrets.AWS_ADDRESS }} + username: ${{ secrets.AWS_USERNAME }} + key: ${{ secrets.AWS_PEM }} + script: | + sleep 10 + curl -f http://localhost/openapi.json + + #Next work through each endpoint and test each one with a single arbitrary example as if we were curling the api from the ubuntu shell + #This is not performing unit testing or showing application functionality + #This verifies that the container running on the AWS server has ports configured correctly and each endpoint can be reached from an external user without raising any HTTP errors + + - name: Testing Location Endpoint with Single Example (Boise) + run: | + sleep 10 + curl -f http://${{ secrets.AWS_ADDRESS }}/location?city=Boise + + - name: Testing Forecast Endpoint with Single Example (Denver) + run: | + sleep 10 + curl -f http://${{ secrets.AWS_ADDRESS }}/forecast?city=Denver + + - name: Testing Clothing Endpoint with Single Example (Phoenix) + run: | + sleep 10 + curl -f -X POST http://${{ secrets.AWS_ADDRESS }}/clothing -H "Content-Type: application/json" -d '{"city":"Phoenix"}' + + - name: Testing Activities Endpoint with Single Example (Washington) + run: | + sleep 10 + curl -f -X POST http://${{ secrets.AWS_ADDRESS }}/activities -H "Content-Type: application/json" -d '{"city":"Washington"}' \ No newline at end of file