From 3a5041fbe60f01daaa43a8c59a0906c29605b8a7 Mon Sep 17 00:00:00 2001 From: Gabriel Coloma Date: Tue, 12 Mar 2024 12:01:10 -0500 Subject: [PATCH 1/5] Revert "Removed Deployment files to test docker-hub.yml" This reverts commit 6716f461985bcc9f928e720b50b2aa199a6c602a. --- .github/workflows/DjangoDeployment.yml | 89 ++++++++++++++++++++++++++ .github/workflows/ReactDeployment.yml | 70 ++++++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 .github/workflows/DjangoDeployment.yml create mode 100644 .github/workflows/ReactDeployment.yml diff --git a/.github/workflows/DjangoDeployment.yml b/.github/workflows/DjangoDeployment.yml new file mode 100644 index 0000000..2539ccd --- /dev/null +++ b/.github/workflows/DjangoDeployment.yml @@ -0,0 +1,89 @@ +# This workflow will build and push a Python application to an Azure Web App when a commit is pushed to your default branch. +# +# This workflow assumes you have already created the target Azure App Service web app. +# For instructions see https://docs.microsoft.com/en-us/azure/app-service/quickstart-python?tabs=bash&pivots=python-framework-flask +# +# To configure this workflow: +# +# 1. Download the Publish Profile for your Azure Web App. You can download this file from the Overview page of your Web App in the Azure Portal. +# For more information: https://docs.microsoft.com/en-us/azure/app-service/deploy-github-actions?tabs=applevel#generate-deployment-credentials +# +# 2. Create a secret in your repository named AZURE_WEBAPP_PUBLISH_PROFILE, paste the publish profile contents as the value of the secret. +# For instructions on obtaining the publish profile see: https://docs.microsoft.com/azure/app-service/deploy-github-actions#configure-the-github-secret +# +# 3. Change the value for the AZURE_WEBAPP_NAME. Optionally, change the PYTHON_VERSION environment variables below. +# +# For more information on GitHub Actions for Azure: https://github.com/Azure/Actions +# For more information on the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples + +name: Build and deploy Python app to Azure Web App + +env: + AZURE_WEBAPP_NAME: lvlupgg-backend # set this to the name of your Azure Web App + PYTHON_VERSION: '3.10' # set this to the Python version to use + +on: + push: + branches: [ "master" ] + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python version + uses: actions/setup-python@v3.0.0 + with: + python-version: ${{ env.PYTHON_VERSION }} + cache: 'pip' + + - name: Create and start virtual environment + run: | + python -m venv venv + source venv/bin/activate + + - name: Install dependencies + run: | + pip install -r requirements.txt + pip install djangorestframework + pip install django-cors-headers + + # Optional: Add step to run tests here (PyTest, Django test suites, etc.) + + - name: Upload artifact for deployment jobs + uses: actions/upload-artifact@v3 + with: + name: python-app + path: | + . + !venv/ + + deploy: + permissions: + contents: none + runs-on: ubuntu-latest + needs: build + environment: + name: 'Development' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v3 + with: + name: python-app + path: . + + - name: 'Deploy to Azure Web App' + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: ${{ env.AZURE_WEBAPP_NAME }} + publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} diff --git a/.github/workflows/ReactDeployment.yml b/.github/workflows/ReactDeployment.yml new file mode 100644 index 0000000..79e8bb0 --- /dev/null +++ b/.github/workflows/ReactDeployment.yml @@ -0,0 +1,70 @@ +# This workflow will build and push a web application to an Azure Static Web App when you change your code. +# +# This workflow assumes you have already created the target Azure Static Web App. +# For instructions see https://docs.microsoft.com/azure/static-web-apps/get-started-portal?tabs=vanilla-javascript +# +# To configure this workflow: +# +# 1. Set up a secret in your repository named AZURE_STATIC_WEB_APPS_API_TOKEN with the value of your Static Web Apps deployment token. +# For instructions on obtaining the deployment token see: https://docs.microsoft.com/azure/static-web-apps/deployment-token-management +# +# 3. Change the values for the APP_LOCATION, API_LOCATION and APP_ARTIFACT_LOCATION, AZURE_STATIC_WEB_APPS_API_TOKEN environment variables (below). +# For instructions on setting up the appropriate configuration values go to https://docs.microsoft.com/azure/static-web-apps/front-end-frameworks +name: Deploy web app to Azure Static Web Apps + +on: + push: + branches: [ "master" ] + pull_request: + types: [opened, synchronize, reopened, closed] + branches: [ "master" ] + +# Environment variables available to all jobs and steps in this workflow +env: + APP_LOCATION: "/" # location of your client code + API_LOCATION: "api" # location of your api source code - optional + APP_ARTIFACT_LOCATION: "build" # location of client code build output + AZURE_STATIC_WEB_APPS_API_TOKEN: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} # secret containing deployment token for your static web app + +permissions: + contents: read + +jobs: + build_and_deploy_job: + permissions: + contents: read # for actions/checkout to fetch code + pull-requests: write # for Azure/static-web-apps-deploy to comment on PRs + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') + runs-on: ubuntu-latest + name: Build and Deploy Job + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - name: Build And Deploy + id: builddeploy + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ env.AZURE_STATIC_WEB_APPS_API_TOKEN }} # secret containing api token for app + repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) + action: "upload" + ###### Repository/Build Configurations - These values can be configured to match you app requirements. ###### + # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig + app_location: ${{ env.APP_LOCATION }} + api_location: ${{ env.API_LOCATION }} + app_artifact_location: ${{ env.APP_ARTIFACT_LOCATION }} + ###### End of Repository/Build Configurations ###### + + close_pull_request_job: + permissions: + contents: none + if: github.event_name == 'pull_request' && github.event.action == 'closed' + runs-on: ubuntu-latest + name: Close Pull Request Job + steps: + - name: Close Pull Request + id: closepullrequest + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ env.AZURE_STATIC_WEB_APPS_API_TOKEN }} # secret containing api token for app + action: "close" From 1f0860b7f00115f8b532a95679082e0b8db50a5f Mon Sep 17 00:00:00 2001 From: Gabriel Coloma Date: Tue, 12 Mar 2024 12:04:15 -0500 Subject: [PATCH 2/5] Updated deployment to work when CI succeeds --- .github/workflows/DjangoDeployment.yml | 5 ++++- .github/workflows/ReactDeployment.yml | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/DjangoDeployment.yml b/.github/workflows/DjangoDeployment.yml index 2539ccd..eb2ccb8 100644 --- a/.github/workflows/DjangoDeployment.yml +++ b/.github/workflows/DjangoDeployment.yml @@ -24,8 +24,11 @@ env: PYTHON_VERSION: '3.10' # set this to the Python version to use on: - push: + workflow_run: branches: [ "master" ] + workflows: ["Django CI", "Node.js CI"] + types: + - completed workflow_dispatch: permissions: diff --git a/.github/workflows/ReactDeployment.yml b/.github/workflows/ReactDeployment.yml index 79e8bb0..d716587 100644 --- a/.github/workflows/ReactDeployment.yml +++ b/.github/workflows/ReactDeployment.yml @@ -13,11 +13,12 @@ name: Deploy web app to Azure Static Web Apps on: - push: - branches: [ "master" ] - pull_request: - types: [opened, synchronize, reopened, closed] + workflow_run: branches: [ "master" ] + workflows: ["Django CI", "Node.js CI"] + types: + - completed + workflow_dispatch: # Environment variables available to all jobs and steps in this workflow env: From fdda44661eecfd0bcee334c9541ad173df8247f3 Mon Sep 17 00:00:00 2001 From: Gabriel Coloma Date: Tue, 12 Mar 2024 18:07:31 -0500 Subject: [PATCH 3/5] Setup deployment files and configurations --- lvlgg_backend/.production | 2 + lvlgg_backend/lvlgg_backend/deployment.py | 47 ++++++++++++++++++++++ lvlgg_backend/lvlgg_backend/settings.py | 1 + lvlgg_backend/lvlgg_backend/wsgi.py | 2 +- lvlgg_backend/manage.py | 1 + lvlgg_backend/requirements.txt | Bin 68 -> 506 bytes 6 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 lvlgg_backend/.production create mode 100644 lvlgg_backend/lvlgg_backend/deployment.py diff --git a/lvlgg_backend/.production b/lvlgg_backend/.production new file mode 100644 index 0000000..6278331 --- /dev/null +++ b/lvlgg_backend/.production @@ -0,0 +1,2 @@ +[config] +SCM_DO_BUILD_DURING_DEPLOYMENT=true \ No newline at end of file diff --git a/lvlgg_backend/lvlgg_backend/deployment.py b/lvlgg_backend/lvlgg_backend/deployment.py new file mode 100644 index 0000000..f1a8859 --- /dev/null +++ b/lvlgg_backend/lvlgg_backend/deployment.py @@ -0,0 +1,47 @@ +import os +from .settings import* +from .settings import BASE_DIR + +ALLOWED_HOSTS = [os.environ['WEBSITE_HOSTNAME']] +CSRF_TRUSTED_ORIGINS = ['https://' + os.environ['WEBSITE_HOSTNAME']] +DEBUG = False +SECRET_KEY = os.environ['MY_SEECRET_KEY'] + +MIDDLEWARE = [ + "django.middleware.security.SecurityMiddleware", + "whitenoise.middleware.WhiteNoiseMiddleWare", + "django.contrib.sessions.middleware.SessionMiddleware", + "corsheaders.middleware.CorsMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", +] + +# CORS_ALLOWED_ORIGINS = ['http://localhost:3000' +# ] + +STORAGES = { + "default": { + "BACKEND": "django.core.files.storage.FileSystemStorage" + }, + "staticfiles": { + "BACCKEND": "whitenoise.storage.CompressedStaticFileStorage" + } +} + +CONNECTION = os.environ['AZURE_POSTGRESQL_CONNECTIONSTRING'] +CONNECTION_STR = {pair.split('=')[0]:pair.split('=')[1] for pair in CONNECTION.split('')} + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.postgresql", + "NAME": CONNECTION_STR['dbname'], + "HOST": CONNECTION_STR['host'], + "USER": CONNECTION_STR['user'], + "PASSWORD": CONNECTION_STR['password'], + } +} + +STATIC_ROOT = BASE_DIR/'staticfiles' \ No newline at end of file diff --git a/lvlgg_backend/lvlgg_backend/settings.py b/lvlgg_backend/lvlgg_backend/settings.py index fdf6451..a9e6ddf 100644 --- a/lvlgg_backend/lvlgg_backend/settings.py +++ b/lvlgg_backend/lvlgg_backend/settings.py @@ -158,6 +158,7 @@ ] CSRF_TRUSTED_ORIGINS = ['http://localhost:3000'] +CORS_ALLOWED_ORIGINS = ['http://localhost:3000'] diff --git a/lvlgg_backend/lvlgg_backend/wsgi.py b/lvlgg_backend/lvlgg_backend/wsgi.py index 2e3b120..7957331 100644 --- a/lvlgg_backend/lvlgg_backend/wsgi.py +++ b/lvlgg_backend/lvlgg_backend/wsgi.py @@ -10,7 +10,7 @@ import os from django.core.wsgi import get_wsgi_application - +settings_module = 'lvlgg_backend.deployment' if 'WEBSITE_HOSTNAME' in os.environ else 'lvlgg_backend.settings' os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lvlgg_backend.settings') application = get_wsgi_application() diff --git a/lvlgg_backend/manage.py b/lvlgg_backend/manage.py index ecdcfa8..a6f9e8d 100755 --- a/lvlgg_backend/manage.py +++ b/lvlgg_backend/manage.py @@ -6,6 +6,7 @@ def main(): """Run administrative tasks.""" + settings_module = 'lvlgg_backend.deployment' if 'WEBSITE_HOSTNAME' in os.environ else 'lvlgg_backend.settings' os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lvlgg_backend.settings') try: from django.core.management import execute_from_command_line diff --git a/lvlgg_backend/requirements.txt b/lvlgg_backend/requirements.txt index fa1e6f053695ca74bf5969b4a4d18bd8dd95790a..ffb925536e99169e6e1106ad9fb604761e3dc636 100644 GIT binary patch literal 506 zcmZ9I-A;p05QOKtiI38TU#%Ct>w6d~RM85j91P&Yx1HI8*cfsMhnb!IcCVKL9&f18 zp~4Y6J}EYM;z{s;754Z*frg&e)SODRsO6oi1dpC69V@#g&ysJy=<1vrljGkBuS|F3O3aZ^eYT@?<+dnspi47_zN*jXgo&i@^fXx0 zSMXMmsOKh5OWyX5NB*B#iP%$H3N)TIqbZsq#v|X6b@4beO|x_)uFRv|i6%2gPfo{r p?e~R_(Ks5qYhw%3%dgo&syG61@sB5D4xFo=b6S4=b{5wk+YPsTO8fu- literal 68 zcmZ?CO3X{ox3x9ZGte{QDk!c@&M!!hPRh(nEUJvPwKdi=)H5{V;z|K4D@rXcNh?as RO)bwa$_7iC=oxTv0Ra1I6>k6l From 1e3d08df8cc18e4323c68ac5385774963282d3ce Mon Sep 17 00:00:00 2001 From: Gabriel Coloma Date: Tue, 12 Mar 2024 19:09:18 -0500 Subject: [PATCH 4/5] Removed CORS_ALLOWED_ORIGINS in settings.py --- lvlgg_backend/lvlgg_backend/settings.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lvlgg_backend/lvlgg_backend/settings.py b/lvlgg_backend/lvlgg_backend/settings.py index a9e6ddf..fdf6451 100644 --- a/lvlgg_backend/lvlgg_backend/settings.py +++ b/lvlgg_backend/lvlgg_backend/settings.py @@ -158,7 +158,6 @@ ] CSRF_TRUSTED_ORIGINS = ['http://localhost:3000'] -CORS_ALLOWED_ORIGINS = ['http://localhost:3000'] From 9efc94b83f6eca29864075bfca0575a8faafa5c7 Mon Sep 17 00:00:00 2001 From: Gabriel Coloma Date: Tue, 12 Mar 2024 20:04:23 -0500 Subject: [PATCH 5/5] Made changes to AzureDeployBackend --- ...pgg-backend.yml => AzureDeployBackend.yml} | 147 ++++++++++-------- .github/workflows/DjangoDeployment.yml | 92 ----------- .github/workflows/ReactDeployment.yml | 71 --------- 3 files changed, 79 insertions(+), 231 deletions(-) rename .github/workflows/{master_lvlupgg-backend.yml => AzureDeployBackend.yml} (85%) delete mode 100644 .github/workflows/DjangoDeployment.yml delete mode 100644 .github/workflows/ReactDeployment.yml diff --git a/.github/workflows/master_lvlupgg-backend.yml b/.github/workflows/AzureDeployBackend.yml similarity index 85% rename from .github/workflows/master_lvlupgg-backend.yml rename to .github/workflows/AzureDeployBackend.yml index bb0a67f..0efc38b 100644 --- a/.github/workflows/master_lvlupgg-backend.yml +++ b/.github/workflows/AzureDeployBackend.yml @@ -1,66 +1,77 @@ -# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy -# More GitHub Actions for Azure: https://github.com/Azure/actions -# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions - -name: Build and deploy Python app to Azure Web App - lvlupgg-backend - -on: - push: - branches: - - master - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python version - uses: actions/setup-python@v1 - with: - python-version: '3.10' - - - name: Create and start virtual environment - run: | - python -m venv venv - source venv/bin/activate - - - name: Install dependencies - run: pip install -r requirements.txt - - # Optional: Add step to run tests here (PyTest, Django test suites, etc.) - - - name: Zip artifact for deployment - run: zip release.zip ./* -r - - - name: Upload artifact for deployment jobs - uses: actions/upload-artifact@v3 - with: - name: python-app - path: | - release.zip - !venv/ - - deploy: - runs-on: ubuntu-latest - needs: build - environment: - name: 'Production' - url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions +# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions + +name: Build and deploy Python app to Azure Web App - lvlupgg-backend + +on: + push: + branches: + - master + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python version + uses: actions/setup-python@v1 + with: + python-version: '3.10' + + - name: Create and start virtual environment + run: | + cd lvlgg_backend + python -m venv venv + source venv/bin/activate + + - name: Install dependencies + run: | + cd backend + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Collect static files + run: | + cd backend + python manage.py collectstatic --noinput + + # Optional: Add step to run tests here (PyTest, Django test suites, etc.) + + - name: Zip artifact for deployment + run: | + cd lvlgg_backend + zip release.zip ./* -r + + - name: Upload artifact for deployment jobs + uses: actions/upload-artifact@v3 + with: + name: python-app + path: | + release.zip + !venv/ + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: 'Production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} permissions: id-token: write #This is required for requesting the JWT - - steps: - - name: Download artifact from build job - uses: actions/download-artifact@v3 - with: - name: python-app - - - name: Unzip artifact for deployment - run: unzip release.zip - + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v3 + with: + name: python-app + + - name: Unzip artifact for deployment + run: unzip release.zip + - name: Login to Azure uses: azure/login@v1 @@ -68,11 +79,11 @@ jobs: client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_D0EC002512024948BEDB0456F467333B }} tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_9D33C22D6BBE444D99A3A90F855A879F }} subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_DD88327B9EFA4CF1B3B7A3B7976C1BAB }} - - - name: 'Deploy to Azure Web App' - uses: azure/webapps-deploy@v2 - id: deploy-to-webapp - with: - app-name: 'lvlupgg-backend' - slot-name: 'Production' + + - name: 'Deploy to Azure Web App' + uses: azure/webapps-deploy@v2 + id: deploy-to-webapp + with: + app-name: 'lvlupgg-backend' + slot-name: 'Production' \ No newline at end of file diff --git a/.github/workflows/DjangoDeployment.yml b/.github/workflows/DjangoDeployment.yml deleted file mode 100644 index eb2ccb8..0000000 --- a/.github/workflows/DjangoDeployment.yml +++ /dev/null @@ -1,92 +0,0 @@ -# This workflow will build and push a Python application to an Azure Web App when a commit is pushed to your default branch. -# -# This workflow assumes you have already created the target Azure App Service web app. -# For instructions see https://docs.microsoft.com/en-us/azure/app-service/quickstart-python?tabs=bash&pivots=python-framework-flask -# -# To configure this workflow: -# -# 1. Download the Publish Profile for your Azure Web App. You can download this file from the Overview page of your Web App in the Azure Portal. -# For more information: https://docs.microsoft.com/en-us/azure/app-service/deploy-github-actions?tabs=applevel#generate-deployment-credentials -# -# 2. Create a secret in your repository named AZURE_WEBAPP_PUBLISH_PROFILE, paste the publish profile contents as the value of the secret. -# For instructions on obtaining the publish profile see: https://docs.microsoft.com/azure/app-service/deploy-github-actions#configure-the-github-secret -# -# 3. Change the value for the AZURE_WEBAPP_NAME. Optionally, change the PYTHON_VERSION environment variables below. -# -# For more information on GitHub Actions for Azure: https://github.com/Azure/Actions -# For more information on the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy -# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples - -name: Build and deploy Python app to Azure Web App - -env: - AZURE_WEBAPP_NAME: lvlupgg-backend # set this to the name of your Azure Web App - PYTHON_VERSION: '3.10' # set this to the Python version to use - -on: - workflow_run: - branches: [ "master" ] - workflows: ["Django CI", "Node.js CI"] - types: - - completed - workflow_dispatch: - -permissions: - contents: read - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python version - uses: actions/setup-python@v3.0.0 - with: - python-version: ${{ env.PYTHON_VERSION }} - cache: 'pip' - - - name: Create and start virtual environment - run: | - python -m venv venv - source venv/bin/activate - - - name: Install dependencies - run: | - pip install -r requirements.txt - pip install djangorestframework - pip install django-cors-headers - - # Optional: Add step to run tests here (PyTest, Django test suites, etc.) - - - name: Upload artifact for deployment jobs - uses: actions/upload-artifact@v3 - with: - name: python-app - path: | - . - !venv/ - - deploy: - permissions: - contents: none - runs-on: ubuntu-latest - needs: build - environment: - name: 'Development' - url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} - - steps: - - name: Download artifact from build job - uses: actions/download-artifact@v3 - with: - name: python-app - path: . - - - name: 'Deploy to Azure Web App' - id: deploy-to-webapp - uses: azure/webapps-deploy@v2 - with: - app-name: ${{ env.AZURE_WEBAPP_NAME }} - publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} diff --git a/.github/workflows/ReactDeployment.yml b/.github/workflows/ReactDeployment.yml deleted file mode 100644 index d716587..0000000 --- a/.github/workflows/ReactDeployment.yml +++ /dev/null @@ -1,71 +0,0 @@ -# This workflow will build and push a web application to an Azure Static Web App when you change your code. -# -# This workflow assumes you have already created the target Azure Static Web App. -# For instructions see https://docs.microsoft.com/azure/static-web-apps/get-started-portal?tabs=vanilla-javascript -# -# To configure this workflow: -# -# 1. Set up a secret in your repository named AZURE_STATIC_WEB_APPS_API_TOKEN with the value of your Static Web Apps deployment token. -# For instructions on obtaining the deployment token see: https://docs.microsoft.com/azure/static-web-apps/deployment-token-management -# -# 3. Change the values for the APP_LOCATION, API_LOCATION and APP_ARTIFACT_LOCATION, AZURE_STATIC_WEB_APPS_API_TOKEN environment variables (below). -# For instructions on setting up the appropriate configuration values go to https://docs.microsoft.com/azure/static-web-apps/front-end-frameworks -name: Deploy web app to Azure Static Web Apps - -on: - workflow_run: - branches: [ "master" ] - workflows: ["Django CI", "Node.js CI"] - types: - - completed - workflow_dispatch: - -# Environment variables available to all jobs and steps in this workflow -env: - APP_LOCATION: "/" # location of your client code - API_LOCATION: "api" # location of your api source code - optional - APP_ARTIFACT_LOCATION: "build" # location of client code build output - AZURE_STATIC_WEB_APPS_API_TOKEN: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} # secret containing deployment token for your static web app - -permissions: - contents: read - -jobs: - build_and_deploy_job: - permissions: - contents: read # for actions/checkout to fetch code - pull-requests: write # for Azure/static-web-apps-deploy to comment on PRs - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') - runs-on: ubuntu-latest - name: Build and Deploy Job - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - name: Build And Deploy - id: builddeploy - uses: Azure/static-web-apps-deploy@v1 - with: - azure_static_web_apps_api_token: ${{ env.AZURE_STATIC_WEB_APPS_API_TOKEN }} # secret containing api token for app - repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) - action: "upload" - ###### Repository/Build Configurations - These values can be configured to match you app requirements. ###### - # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig - app_location: ${{ env.APP_LOCATION }} - api_location: ${{ env.API_LOCATION }} - app_artifact_location: ${{ env.APP_ARTIFACT_LOCATION }} - ###### End of Repository/Build Configurations ###### - - close_pull_request_job: - permissions: - contents: none - if: github.event_name == 'pull_request' && github.event.action == 'closed' - runs-on: ubuntu-latest - name: Close Pull Request Job - steps: - - name: Close Pull Request - id: closepullrequest - uses: Azure/static-web-apps-deploy@v1 - with: - azure_static_web_apps_api_token: ${{ env.AZURE_STATIC_WEB_APPS_API_TOKEN }} # secret containing api token for app - action: "close"