44278596c1
* Secure workflows (#1) (#1072) * Restrict permissions for the GITHUB_TOKEN in .github/workflows/label-feature.yml * Restrict permissions for the GITHUB_TOKEN in .github/workflows/label-support.yml * Restrict permissions for the GITHUB_TOKEN in .github/workflows/stale.yml * Restrict permissions for the GITHUB_TOKEN in .github/workflows/sync_ghes.yaml * Restrict permissions for the GITHUB_TOKEN in .github/workflows/validate-data.yaml Co-authored-by: Step Security <bot@stepsecurity.io> Co-authored-by: step-security[bot] <89328102+step-security[bot]@users.noreply.github.com> Co-authored-by: Step Security <bot@stepsecurity.io> * Directory for deployments (#1071) * moving deployment templates * including deployment directory in scripts * validate categories script init * introducing scout * introducing workflow * Update validate-categories.yaml * Update validate-categories.yaml * Update validate-categories.yaml * Update validate.rb * Update validate.rb * Update validate.rb * Update validate.rb * Update validate-categories.yaml * Update validate-categories.yaml * Update validate-categories.yaml * Update validate.rb * Update validate-categories.yaml * Update validate-categories.yaml * Create test_comment.yaml * rename * using [enter] * testing newline * test * setting up variable * using echo -e * using join * testing space space new line * setting multi line in echo * removing checkout * setting rows-generator * fixing error * using join * commit * Update test_comment.yaml * escaping pipe * printing debug line * using %0A * Update validate-categories.yaml * Update validate.rb * Update validate.rb * removing debug * removing variable * Update validate.rb * Update validate-categories.yaml * Validate categories comment on pr (#32) * reverting deployment directory * checking for output * Categories validation two workflows (#34) comment on pr in a separate workflow * Categories validation two workflows (#35) using right dir name * Categories validation two workflows (#36) . * Categories validation two workflows (#37) fixing typo * adding if conditions * adding try catch * using console instead of echo * equating to upstream * moving deployment templates * add codeql workflow to ghes * restoring from main (#1078) * Revert "add codeql workflow to ghes branch" * add codeql workflow to ghes * only run ghes sync checks on YML files * only check nwo of supported actions * Testing Partner Toggle. Co-authored-by: Varun Sharma <varunsh@stepsecurity.io> Co-authored-by: step-security[bot] <89328102+step-security[bot]@users.noreply.github.com> Co-authored-by: Step Security <bot@stepsecurity.io> Co-authored-by: Aparna Ravindra <82894348+aparna-ravindra@users.noreply.github.com> Co-authored-by: Nick Fyson <nickfyson@github.com>
120 lines
4.4 KiB
YAML
120 lines
4.4 KiB
YAML
# 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 a release is created.
|
|
#
|
|
# 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:
|
|
release:
|
|
types: [created]
|
|
|
|
# Environment variables available to all jobs and steps in this workflow.
|
|
env:
|
|
REGION_ID: cn-hangzhou
|
|
REGISTRY: registry.cn-hangzhou.aliyuncs.com
|
|
NAMESPACE: namespace
|
|
IMAGE: repo
|
|
TAG: ${{ github.sha }}
|
|
ACK_CLUSTER_ID: clusterID
|
|
ACK_DEPLOYMENT_NAME: nginx-deployment
|
|
|
|
ACR_EE_REGISTRY: myregistry.cn-hangzhou.cr.aliyuncs.com
|
|
ACR_EE_INSTANCE_ID: instanceID
|
|
ACR_EE_NAMESPACE: namespace
|
|
ACR_EE_IMAGE: repo
|
|
ACR_EE_TAG: ${{ github.sha }}
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
environment: production
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
|
|
# 1.1 Login to ACR
|
|
- name: Login to ACR with the AccessKey pair
|
|
uses: aliyun/acr-login@v1
|
|
with:
|
|
region-id: "${{ env.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: "${{ env.REGION_ID }}"
|
|
access-key-id: "${{ secrets.ACCESS_KEY_ID }}"
|
|
access-key-secret: "${{ secrets.ACCESS_KEY_SECRET }}"
|
|
repository: "${{ env.NAMESPACE }}/${{ env.IMAGE }}"
|
|
tag: "${{ env.TAG }}"
|
|
|
|
# 2.1 (Optional) Login to ACR EE
|
|
- uses: actions/checkout@v2
|
|
- name: Login to ACR EE with the AccessKey pair
|
|
uses: aliyun/acr-login@v1
|
|
with:
|
|
login-server: "https://${{ env.ACR_EE_REGISTRY }}"
|
|
region-id: "${{ env.REGION_ID }}"
|
|
access-key-id: "${{ secrets.ACCESS_KEY_ID }}"
|
|
access-key-secret: "${{ secrets.ACCESS_KEY_SECRET }}"
|
|
instance-id: "${{ env.ACR_EE_INSTANCE_ID }}"
|
|
|
|
# 2.2 (Optional) Build and push image ACR EE
|
|
- name: Build and push image to ACR EE
|
|
run: |
|
|
docker build -t "$ACR_EE_REGISTRY/$ACR_EE_NAMESPACE/$ACR_EE_IMAGE:$TAG" .
|
|
docker push "$ACR_EE_REGISTRY/$ACR_EE_NAMESPACE/$ACR_EE_IMAGE:$TAG"
|
|
# 2.3 (Optional) Scan image in ACR EE
|
|
- name: Scan image in ACR EE
|
|
uses: aliyun/acr-scan@v1
|
|
with:
|
|
region-id: "${{ env.REGION_ID }}"
|
|
access-key-id: "${{ secrets.ACCESS_KEY_ID }}"
|
|
access-key-secret: "${{ secrets.ACCESS_KEY_SECRET }}"
|
|
instance-id: "${{ env.ACR_EE_INSTANCE_ID }}"
|
|
repository: "${{ env.ACR_EE_NAMESPACE}}/${{ env.ACR_EE_IMAGE }}"
|
|
tag: "${{ env.ACR_EE_TAG }}"
|
|
|
|
# 3.1 Set ACK context
|
|
- name: Set K8s context
|
|
uses: aliyun/ack-set-context@v1
|
|
with:
|
|
access-key-id: "${{ secrets.ACCESS_KEY_ID }}"
|
|
access-key-secret: "${{ secrets.ACCESS_KEY_SECRET }}"
|
|
cluster-id: "${{ env.ACK_CLUSTER_ID }}"
|
|
|
|
# 3.2 Deploy the image to the ACK cluster
|
|
- name: Set up Kustomize
|
|
run: |-
|
|
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash /dev/stdin 3.8.6
|
|
- name: Deploy
|
|
run: |-
|
|
./kustomize edit set image REGISTRY/NAMESPACE/IMAGE:TAG=$REGISTRY/$NAMESPACE/$IMAGE:$TAG
|
|
./kustomize build . | kubectl apply -f -
|
|
kubectl rollout status deployment/$ACK_DEPLOYMENT_NAME
|
|
kubectl get services -o wide
|