Merge pull request #1 from PPKoller/PPKoller-patch-1 #28
This file contains hidden or 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
| # This workflow uses actions that are not certified by GitHub. | |
| # They are provided by a third-party and are governed by | |
| # separate terms of service, privacy policy, and support | |
| # documentation. | |
| # GitHub recommends pinning actions to a commit SHA. | |
| # To get a newer version, you will need to update the SHA. | |
| # You can also reference a tag or branch, but the action may change without warning. | |
| name: Build and deploy Python app to Azure Web App | |
| env: | |
| AZURE_WEBAPP_NAME: flask-githubactions # set this to your application's name | |
| PYTHON_VERSION: '3.12' # set this to the Python version to use | |
| on: | |
| push: | |
| branches: [ main , master ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python version | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Create and start virtual environment | |
| run: | | |
| python -m venv venv | |
| source venv/bin/activate | |
| - name: Set up dependency caching for faster installs | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: pip install -r requirements.txt | |
| - name: Test | |
| run: make test | |
| - name: Upload artifact for deployment jobs | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-app | |
| path: | | |
| . | |
| !venv/ | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| environment: | |
| name: 'production' | |
| url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | |
| steps: | |
| - name: Download artifact from build job | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-app | |
| path: . | |
| - name: 'Deploy to Azure Web App' | |
| id: deploy-to-webapp | |
| uses: azure/webapps-deploy@85270a1854658d167ab239bce43949edb336fa7c | |
| with: | |
| app-name: ${{ env.AZURE_WEBAPP_NAME }} | |
| publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} |