diff --git a/.github/workflows/ci-pipeline.yml b/.github/workflows/ci-pipeline.yml index 53ab7ab..4d77b93 100644 --- a/.github/workflows/ci-pipeline.yml +++ b/.github/workflows/ci-pipeline.yml @@ -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 - \ No newline at end of file + - 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 }}' + diff --git a/README.md b/README.md index 39cee88..6abb385 100644 --- a/README.md +++ b/README.md @@ -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/` @@ -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"`