-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5561a21
commit 1cd2a07
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# This workflow will build and push a new container image to Alibaba Cloud Container Registry (ACR), | ||
# and then will deploy it to Alibaba Cloud Container Service for Kubernetes (ACK), when there is a push to the "master" branch. | ||
# | ||
# To use this workflow, you will need to complete the following set-up steps: | ||
# | ||
# 1. Create an ACR repository to store your container images. | ||
# You can use ACR EE instance for more security and better performance. | ||
# For instructions see https://www.alibabacloud.com/help/doc-detail/142168.htm | ||
# | ||
# 2. Create an ACK cluster to run your containerized application. | ||
# You can use ACK Pro cluster for more security and better performance. | ||
# For instructions see https://www.alibabacloud.com/help/doc-detail/95108.htm | ||
# | ||
# 3. Store your AccessKey pair in GitHub Actions secrets named `ACCESS_KEY_ID` and `ACCESS_KEY_SECRET`. | ||
# For instructions on setting up secrets see: https://developer.github.com/actions/managing-workflows/storing-secrets/ | ||
# | ||
# 4. Change the values for the REGION_ID, REGISTRY, NAMESPACE, IMAGE, ACK_CLUSTER_ID, and ACK_DEPLOYMENT_NAME. | ||
# | ||
|
||
name: Build and Deploy to ACK | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
|
||
# Environment variables available to all jobs and steps in this workflow. | ||
env: | ||
TAG: ${{ github.sha }} | ||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
environment: production | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
# 1.1 Login to ACR | ||
- name: Login to ACR with the AccessKey pair | ||
uses: aliyun/acr-login@v1 | ||
with: | ||
region-id: "${{ secrets.REGION_ID }}" | ||
access-key-id: "${{ secrets.ACCESS_KEY_ID }}" | ||
access-key-secret: "${{ secrets.ACCESS_KEY_SECRET }}" | ||
|
||
# 1.2 Buid and push image to ACR | ||
- name: Build and push image to ACR | ||
run: | | ||
docker build --tag "$REGISTRY/$NAMESPACE/$IMAGE:$TAG" . | ||
docker push "$REGISTRY/$NAMESPACE/$IMAGE:$TAG" | ||
# 1.3 Scan image in ACR | ||
- name: Scan image in ACR | ||
uses: aliyun/acr-scan@v1 | ||
with: | ||
region-id: "${{ secrets.REGION_ID }}" | ||
access-key-id: "${{ secrets.ACCESS_KEY_ID }}" | ||
access-key-secret: "${{ secrets.ACCESS_KEY_SECRET }}" | ||
repository: "${{ secrets.NAMESPACE }}/${{ secrets.IMAGE }}" | ||
tag: "${{ env.TAG }}" |