Display git SHA #2
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
| name: CI/CD pipeline | ||
|
Check failure on line 1 in .github/workflows/ci-cd.yml
|
||
| env: | ||
| AZURE_WEBAPP_NAME: cloud-counter | ||
| PYTHON_VERSION: '3.14' | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check out repository code | ||
| - uses: actions/checkout@v6 | ||
| - name: Update commit hash | ||
| run: | | ||
| SHORT_SHA=$(echo "${GITHUB_SHA}" | cut -c1-7) | ||
| sed -i "s/9eec34d2-fa74-413c-a262-4a7ec75baa90/$SHORT_SHA/g" templates/index.html | ||
| - 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@v4 | ||
| 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: Upload artifact for deployment jobs | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: cloud-counter | ||
| path: | | ||
| app.py | ||
| requirements.txt | ||
| templates/ | ||
| 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@v5 | ||
| with: | ||
| name: cloud-counter | ||
| 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 }} | ||