Skip to content

Commit

Permalink
First attempt to set up automatic deployment from github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
CalPinSW committed Jul 17, 2024
1 parent 9b5a4a5 commit f340150
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
36 changes: 32 additions & 4 deletions .github/workflows/ci-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,41 @@ jobs:
run: docker run --env-file backend/.env.test backend:test

publish:
name: Publish
name: Publish To Docker
runs-on: ubuntu-latest
needs: build
if: ${{ (github.ref == 'refs/heads/continuous-deployment-to-azure') && (github.event_name == 'push') }}
steps:
- name: Placeholder
run: echo Publishing
- name: Checkout Repository
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}

- name: Build frontend Docker image
working-directory: frontend
run: docker build --target development --tag frontend:${{ github.sha }} .
- name: Push frontend Docker image
working-directory: frontend
run: docker push calpin/frontend:${{ github.sha }}

- name: Build backend Docker image
working-directory: backend
run: docker build --target development --tag backend:${{ github.sha }} .
- name: Push backend Docker image
working-directory: backend
run: docker push calpin/backend:${{ github.sha }}

deploy:
name: Deploy to Azure
runs-on: ubuntu-latest
needs: publish
if: ${{ (github.ref == 'refs/heads/continuous-deployment-to-azure') && (github.event_name == 'push') }}
steps:
- name: Trigger Azure frontend deployment webhook
run: curl -dH -X POST '${{ secrets.AZURE_DEPLOYMENT_WEBHOOK_FRONTEND }}'
- name: Trigger Azure backend deployment webhook
run: curl -dH -X POST '${{ secrets.AZURE_DEPLOYMENT_WEBHOOK_BACKEND }}'

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ Install [Docker](https://www.docker.com/products/docker-desktop/) (Windows insta

From the project root run `docker compose up`

From the frontend directory, build the backend in development mode with `docker build --target development --tag backend:dev .`
From the frontend directory, build the frontend in development mode with `docker build --target development --tag frontend:dev .`

From the backend directory, build the frontend in development mode with `docker build --target development --tag frontend:dev .`
From the backend directory, build the backend in development mode with `docker build --target development --tag backend:dev .`

Build backend tests docker image with `docker build --target test --tag backend:test ./backend/`

Expand Down Expand Up @@ -76,5 +76,5 @@ The frontend and backend applications are deployed to two Azure Web Applications
1. Building new Docker images with (from the relevant frontend/backend directory) `docker build --target production --tag calpin/playlist-manager-"frontend/backend":prod .`
2. Pushing the new image to Docker Hub `docker push calpin/playlist-manager-"frontend/backend":prod`
3. Sending a curl request to the appropriate Webhook url:
- Frontend: `curl -dH -X POST "https://\$PlayMan:d17p8pbD0t6xpCdep4tPdetcbsTlZiomZ6kwAwuJB9XaXwjE5hmmgSpBTYqQ@playman.scm.azurewebsites.net/api/registry/webhook"`
- Backend: `curl -dH -X POST "https://\$PlayManBackend:aBPc2NHMrYLEHQtmPB1JhQKgtsonxezPjliwxptyx2142STiv91aRxmnmKe6@playmanbackend.scm.azurewebsites.net/api/registry/webhook"`
- Frontend: `curl -dH -X POST "Frontend Webhook from Azure"`
- Backend: `curl -dH -X POST "Backend Webhook from Azure"`

0 comments on commit f340150

Please sign in to comment.