Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev1 #106

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

Dev1 #106

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/dev1_cicd-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy container app to Azure Web App - cicd-docker

on:
push:
branches:
- dev1
workflow_dispatch:

jobs:
build:
runs-on: 'ubuntu-latest'

steps:
- uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2




- name: Log in to registry
uses: docker/[email protected]
with:
registry: https://ghcr.io/
username: ${{ secrets.AzureAppService_ContainerUsername_0662e63fa3694eeebfb3e991e27936ca }}
password: ${{ secrets.AzureAppService_ContainerPassword_8e51194ff5ea4c38b91386c854241fbe }}

- name: Build and push container image to registry
uses: docker/build-push-action@v3
with:
push: true
tags: ghcr.io/${{ secrets.AzureAppService_ContainerUsername_0662e63fa3694eeebfb3e991e27936ca }}/appsvc/staticsite:${{ github.sha }}
file: ./Dockerfile

deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'cicd-docker'
slot-name: 'production'
publish-profile: ${{ secrets.AzureAppService_PublishProfile_6074368e92f4496ebf08ec0f8238e59f }}
images: 'ghcr.io/${{ secrets.AzureAppService_ContainerUsername_0662e63fa3694eeebfb3e991e27936ca }}/appsvc/staticsite:${{ github.sha }}'
53 changes: 53 additions & 0 deletions .github/workflows/dev1_docker-cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy container app to Azure Web App - docker-cicd

on:
push:
branches:
- dev1
workflow_dispatch:

jobs:
build:
runs-on: 'ubuntu-latest'

steps:
- uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ secrets.AzureAppService_ContainerUsername_70e6045170104b8997d27697b11cdfd0 }}
password: ${{ secrets.AzureAppService_ContainerPassword_4e4dafdefa504043a4aada246d62cf72 }}



- name: Build and push container image to registry
uses: docker/build-push-action@v3
with:
push: true
tags: ghcr.io/stacyhaha/python-sample-vscode-flask-tutorial/myapp:${{ github.sha }}
file: ./Dockerfile

deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'docker-cicd'
slot-name: 'production'
publish-profile: ${{ secrets.AzureAppService_PublishProfile_e90c69f2bc964901a9a6348a135e00d5 }}
images: 'ghcr.io/${{ secrets.AzureAppService_ContainerUsername_70e6045170104b8997d27697b11cdfd0 }}/appsvc/staticsite:${{ github.sha }}'
70 changes: 70 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# 此工作流使用未经 GitHub 认证的操作。
# 它们由第三方提供,并受
# 单独的服务条款、隐私政策和支持
# 文档。

# GitHub 建议将操作固定到提交 SHA。
# 若要获取较新版本,需要更新 SHA。
# 还可以引用标记或分支,但该操作可能会更改而不发出警告。

name: Build and deploy a container to an Azure Web App

env:
AZURE_WEBAPP_NAME: cicd-docker # set this to your application's name

on:
push:
branches:
- dev1

permissions:
contents: 'read'
packages: 'write'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b

- name: Log in to GitHub container registry
uses: docker/login-action@8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Lowercase the repo name
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}

- name: Build and push container image to registry
uses: docker/build-push-action@9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f
with:
push: true
tags: ghcr.io/${{ env.REPO }}:${{ github.sha }}
file: ./Dockerfile

deploy:
runs-on: ubuntu-latest

needs: build

environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Lowercase the repo name
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}

- 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_DOCKER }}
images: 'ghcr.io/${{ env.REPO }}:${{ github.sha }}'
78 changes: 78 additions & 0 deletions .github/workflows/main_cicd-demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# 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 - cicd-demo

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python version
uses: actions/setup-python@v5
with:
python-version: '3.8'

- 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@v4
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@v4
with:
name: python-app

- name: Unzip artifact for deployment
run: unzip release.zip


- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_5FB268B98CFE44E0BEEED5F540A2839B }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_3EBFE7E2825942458DDF8947751539A7 }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_4C16A9EE9B4845589A178E3565C8667A }}

- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v3
id: deploy-to-webapp
with:
app-name: 'cicd-demo'
slot-name: 'Production'

2 changes: 1 addition & 1 deletion hello_app/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
Home
{% endblock %}
{% block content %}
<p>Home page for the Visual Studio Code Flask tutorial.</p>
<p>avoid bypass check main protection: Home page for the Visual Studio Code Flask tutorial.</p>
{% endblock %}