Merge b269d41e85 into 9a951055f0
This commit is contained in:
commit
371f23d510
3 changed files with 277 additions and 0 deletions
86
.github/workflows/azure-container-webapp.yml
vendored
Normal file
86
.github/workflows/azure-container-webapp.yml
vendored
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
# This workflow will build and push a Docker container 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-custom-container?tabs=dotnet&pivots=container-linux
|
||||
#
|
||||
# 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. Create a GitHub Personal access token with "repo" and "read:packages" permissions.
|
||||
#
|
||||
# 4. Create three app settings on your Azure Web app:
|
||||
# DOCKER_REGISTRY_SERVER_URL: Set this to "https://ghcr.io"
|
||||
# DOCKER_REGISTRY_SERVER_USERNAME: Set this to the GitHub username or organization that owns the repository
|
||||
# DOCKER_REGISTRY_SERVER_PASSWORD: Set this to the value of your PAT token from the previous step
|
||||
#
|
||||
# 5. Change the value for the AZURE_WEBAPP_NAME.
|
||||
#
|
||||
# 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 a container to an Azure Web App
|
||||
|
||||
env:
|
||||
AZURE_WEBAPP_NAME: your-app-name # set this to the name of your Azure Web App
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
|
||||
|
||||
- name: Log in to GitHub container registry
|
||||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ github.token }}
|
||||
|
||||
- name: Lowercase the repo name and username
|
||||
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
|
||||
|
||||
- name: Build and push container image to registry
|
||||
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
|
||||
with:
|
||||
push: true
|
||||
tags: ghcr.io/${{ env.REPO }}:${{ github.sha }}
|
||||
file: ./Dockerfile
|
||||
|
||||
deploy:
|
||||
permissions:
|
||||
contents: none
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
environment:
|
||||
name: 'Development'
|
||||
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
|
||||
|
||||
steps:
|
||||
- name: Lowercase the repo name and username
|
||||
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
|
||||
|
||||
- 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 }}
|
||||
images: 'ghcr.io/${{ env.REPO }}:${{ github.sha }}'
|
||||
112
.github/workflows/octopusdeploy.yml
vendored
Normal file
112
.github/workflows/octopusdeploy.yml
vendored
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
# 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.
|
||||
#
|
||||
# This workflow will build and publish a Docker container which is then deployed through Octopus Deploy.
|
||||
#
|
||||
# The build job in this workflow currently assumes that there is a Dockerfile that generates the relevant application image.
|
||||
# If required, this job can be modified to generate whatever alternative build artifact is required for your deployment.
|
||||
#
|
||||
# This workflow assumes you have already created a Project in Octopus Deploy.
|
||||
# For instructions see https://octopus.com/docs/projects/setting-up-projects
|
||||
#
|
||||
# To configure this workflow:
|
||||
#
|
||||
# 1. Decide where you are going to host your image.
|
||||
# This template uses the GitHub Registry for simplicity but if required you can update the relevant DOCKER_REGISTRY variables below.
|
||||
#
|
||||
# 2. Create and configure an OIDC credential for a service account in Octopus.
|
||||
# This allows for passwordless authentication to your Octopus instance through a trust relationship configured between Octopus, GitHub and your GitHub Repository.
|
||||
# https://octopus.com/docs/octopus-rest-api/openid-connect/github-actions
|
||||
#
|
||||
# 3. Configure your Octopus project details below:
|
||||
# OCTOPUS_URL: update to your Octopus Instance Url
|
||||
# OCTOPUS_SERVICE_ACCOUNT: update to your service account Id
|
||||
# OCTOPUS_SPACE: update to the name of the space your project is configured in
|
||||
# OCTOPUS_PROJECT: update to the name of your Octopus project
|
||||
# OCTOPUS_ENVIRONMENT: update to the name of the environment to recieve the first deployment
|
||||
|
||||
|
||||
name: 'Build and Deploy to Octopus Deploy'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '"main"'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
packages: write
|
||||
contents: read
|
||||
env:
|
||||
DOCKER_REGISTRY: ghcr.io # TODO: Update to your docker registry uri
|
||||
DOCKER_REGISTRY_USERNAME: ${{ github.actor }} # TODO: Update to your docker registry username
|
||||
DOCKER_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} # TODO: Update to your docker registry password
|
||||
outputs:
|
||||
image_tag: ${{ steps.meta.outputs.version }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
|
||||
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
|
||||
with:
|
||||
registry: ${{ env.DOCKER_REGISTRY }}
|
||||
username: ${{ env.DOCKER_REGISTRY_USERNAME }}
|
||||
password: ${{ env.DOCKER_REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
|
||||
with:
|
||||
images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}
|
||||
tags: type=semver,pattern={{version}},value=v1.0.0-{{sha}}
|
||||
|
||||
- name: Build and push Docker image
|
||||
id: push
|
||||
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
deploy:
|
||||
name: Deploy
|
||||
permissions:
|
||||
id-token: write
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ build ]
|
||||
env:
|
||||
OCTOPUS_URL: 'https://your-octopus-url' # TODO: update to your Octopus Instance url
|
||||
OCTOPUS_SERVICE_ACCOUNT: 'your-service-account-id' # TODO: update to your service account Id
|
||||
OCTOPUS_SPACE: 'your-space' # TODO: update to the name of the space your project is configured in
|
||||
OCTOPUS_PROJECT: 'your-project' # TODO: update to the name of your Octopus project
|
||||
OCTOPUS_ENVIRONMENT: 'your-environment' # TODO: update to the name of the environment to recieve the first deployment
|
||||
|
||||
steps:
|
||||
- name: Login to Octopus Deploy
|
||||
uses: OctopusDeploy/login@34b6dcc1e86fa373c14e6a28c5507d221e4de629 #v1.0.2
|
||||
with:
|
||||
server: '${{ env.OCTOPUS_URL }}'
|
||||
service_account_id: '${{ env.OCTOPUS_SERVICE_ACCOUNT }}'
|
||||
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: OctopusDeploy/create-release-action@fea7e7b45c38c021b6bc5a14bd7eaa2ed5269214 #v3.2.2
|
||||
with:
|
||||
project: '${{ env.OCTOPUS_PROJECT }}'
|
||||
space: '${{ env.OCTOPUS_SPACE }}'
|
||||
packages: '*:${{ needs.build.outputs.image_tag }}'
|
||||
|
||||
- name: Deploy Release
|
||||
uses: OctopusDeploy/deploy-release-action@b10a606c903b0a5bce24102af9d066638ab429ac #v3.2.1
|
||||
with:
|
||||
project: '${{ env.OCTOPUS_PROJECT }}'
|
||||
space: '${{ env.OCTOPUS_SPACE }}'
|
||||
release_number: '${{ steps.create_release.outputs.release_number }}'
|
||||
environments: ${{ env.OCTOPUS_ENVIRONMENT }}
|
||||
79
.github/workflows/tencent.yml
vendored
Normal file
79
.github/workflows/tencent.yml
vendored
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
# This workflow will build a docker container, publish and deploy it to Tencent Kubernetes Engine (TKE) when there is a push to the "main" branch.
|
||||
#
|
||||
# To configure this workflow:
|
||||
#
|
||||
# 1. Ensure that your repository contains the necessary configuration for your Tencent Kubernetes Engine cluster,
|
||||
# including deployment.yml, kustomization.yml, service.yml, etc.
|
||||
#
|
||||
# 2. Set up secrets in your workspace:
|
||||
# - TENCENT_CLOUD_SECRET_ID with Tencent Cloud secret id
|
||||
# - TENCENT_CLOUD_SECRET_KEY with Tencent Cloud secret key
|
||||
# - TENCENT_CLOUD_ACCOUNT_ID with Tencent Cloud account id
|
||||
# - TKE_REGISTRY_PASSWORD with TKE registry password
|
||||
#
|
||||
# 3. Change the values for the TKE_IMAGE_URL, TKE_REGION, TKE_CLUSTER_ID and DEPLOYMENT_NAME environment variables (below).
|
||||
|
||||
name: Tencent Kubernetes Engine
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
|
||||
# Environment variables available to all jobs and steps in this workflow
|
||||
env:
|
||||
TKE_IMAGE_URL: ccr.ccs.tencentyun.com/demo/mywebapp
|
||||
TKE_REGION: ap-guangzhou
|
||||
TKE_CLUSTER_ID: cls-mywebapp
|
||||
DEPLOYMENT_NAME: tke-test
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
setup-build-publish-deploy:
|
||||
name: Setup, Build, Publish, and Deploy
|
||||
runs-on: ubuntu-latest
|
||||
environment: production
|
||||
steps:
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Build
|
||||
- name: Build Docker image
|
||||
run: |
|
||||
docker build -t ${TKE_IMAGE_URL}:${GITHUB_SHA} .
|
||||
|
||||
- name: Login TKE Registry
|
||||
run: |
|
||||
docker login -u ${{ secrets.TENCENT_CLOUD_ACCOUNT_ID }} -p '${{ secrets.TKE_REGISTRY_PASSWORD }}' ${TKE_IMAGE_URL}
|
||||
|
||||
# Push the Docker image to TKE Registry
|
||||
- name: Publish
|
||||
run: |
|
||||
docker push ${TKE_IMAGE_URL}:${GITHUB_SHA}
|
||||
|
||||
- name: Set up Kustomize
|
||||
run: |
|
||||
curl -o kustomize --location https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64
|
||||
chmod u+x ./kustomize
|
||||
|
||||
- name: Set up ~/.kube/config for connecting TKE cluster
|
||||
uses: TencentCloud/tke-cluster-credential-action@v1
|
||||
with:
|
||||
secret_id: ${{ secrets.TENCENT_CLOUD_SECRET_ID }}
|
||||
secret_key: ${{ secrets.TENCENT_CLOUD_SECRET_KEY }}
|
||||
tke_region: ${{ env.TKE_REGION }}
|
||||
cluster_id: ${{ env.TKE_CLUSTER_ID }}
|
||||
|
||||
- name: Switch to TKE context
|
||||
run: |
|
||||
kubectl config use-context ${TKE_CLUSTER_ID}-context-default
|
||||
|
||||
# Deploy the Docker image to the TKE cluster
|
||||
- name: Deploy
|
||||
run: |
|
||||
./kustomize edit set image ${TKE_IMAGE_URL}:${GITHUB_SHA}
|
||||
./kustomize build . | kubectl apply -f -
|
||||
kubectl rollout status deployment/${DEPLOYMENT_NAME}
|
||||
kubectl get services -o wide
|
||||
Loading…
Reference in a new issue