webapp prod #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD for TFG | |
on: | |
push: | |
branches: | |
- develop | |
pull_request: | |
branches: | |
- develop | |
release: | |
types: [published] | |
jobs: | |
build-and-push-to-acr: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Log in to GitHub Packages | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Pull webapp image from GitHub Packages | |
run: docker pull ghcr.io/${{ github.repository_owner }}/webapp:latest | |
- name: Pull restapi image from GitHub Packages | |
run: docker pull ghcr.io/${{ github.repository_owner }}/restapi:latest | |
- name: Log in to Azure | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Tag and push webapp Docker image to ACR | |
run: | | |
docker tag ghcr.io/${{ github.repository_owner }}/webapp:latest ${{ secrets.REGISTRY_NAME }}.azurecr.io/webapp:latest | |
echo ${{ secrets.REGISTRY_PASSWORD }} | docker login ${{ secrets.REGISTRY_NAME }}.azurecr.io --username ${{ secrets.REGISTRY_USERNAME }} --password-stdin | |
docker push ${{ secrets.REGISTRY_NAME }}.azurecr.io/webapp:latest | |
- name: Tag and push restapi Docker image to ACR | |
run: | | |
docker tag ghcr.io/${{ github.repository_owner }}/restapi:latest ${{ secrets.REGISTRY_NAME }}.azurecr.io/restapi:latest | |
echo ${{ secrets.REGISTRY_PASSWORD }} | docker login ${{ secrets.REGISTRY_NAME }}.azurecr.io --username ${{ secrets.REGISTRY_USERNAME }} --password-stdin | |
docker push ${{ secrets.REGISTRY_NAME }}.azurecr.io/restapi:latest | |
deploy-to-app-service: | |
name: Deploy to Azure App Service | |
runs-on: ubuntu-latest | |
needs: build-and-push-to-acr | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Log in to Azure | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Deploy Docker Compose to Azure Web App | |
uses: azure/webapps-deploy@v2 | |
with: | |
app-name: BidMonUniverse | |
slot-name: production | |
images: | | |
tfgbidmonuniverseregistry.azurecr.io/webapp:latest | |
tfgbidmonuniverseregistry.azurecr.io/restapi:latest | |
configuration-file: docker-compose.yml |