ci: simplify generated consts flows (#4536)

This commit is contained in:
Jack Francis 2021-06-28 16:49:09 -07:00 коммит произвёл GitHub
Родитель 1a8c2a24a2
Коммит aa56294ec2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 9 добавлений и 66 удалений

20
.github/workflows/generate-azure-consts.yaml поставляемый
Просмотреть файл

@ -12,24 +12,16 @@ jobs:
uses: actions/setup-go@v2
with:
go-version: '^1.16'
- name: Build aks-engine binary
run: make build-binary
- name: create generated constants
env:
SUBSCRIPTION_ID: ${{ secrets.TEST_AZURE_SUB_ID }}
CLIENT_ID: ${{ secrets.TEST_AZURE_SP_ID }}
CLIENT_SECRET: ${{ secrets.TEST_AZURE_SP_PW }}
TENANT_ID: ${{ secrets.TEST_AZURE_TENANT_ID }}
run: scripts/azure-const.sh
- name: reset go mod
if: ${{ failure() }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.TEST_AZURE_SUB_ID }}
AZURE_CLIENT_ID: ${{ secrets.TEST_AZURE_SP_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.TEST_AZURE_SP_PW }}
run: |
git checkout -- go.mod
git checkout -- go.sum
git checkout -- hack/tools/go.mod
git checkout -- hack/tools/go.sum
make generate-azure-constants
git diff-index --quiet HEAD -- || echo "MAKE_PR=true" >> $GITHUB_ENV
- name: create pull request
if: ${{ failure() }}
if: ${{ env.MAKE_PR == "true" }}
uses: peter-evans/create-pull-request@v3
with:
commit-message: 'chore: Update Azure constants'

Просмотреть файл

@ -84,10 +84,10 @@ generate: bootstrap
go generate $(GOFLAGS) -v ./... > /dev/null 2>&1
.PHONY: generate-azure-constants
generate-azure-constants:
aks-engine get-locations -o code --client-id=$(AZURE_CLIENT_ID) --client-secret=$(AZURE_CLIENT_SECRET) --subscription-id=$(AZURE_SUBSCRIPTION_ID) \
generate-azure-constants: build-binary
$(BINARY_DEST_DIR)/aks-engine get-locations -o code --client-id=$(AZURE_CLIENT_ID) --client-secret=$(AZURE_CLIENT_SECRET) --subscription-id=$(AZURE_SUBSCRIPTION_ID) \
> pkg/helpers/azure_locations.go
aks-engine get-skus -o code --client-id=$(AZURE_CLIENT_ID) --client-secret=$(AZURE_CLIENT_SECRET) --subscription-id=$(AZURE_SUBSCRIPTION_ID) \
$(BINARY_DEST_DIR)/aks-engine get-skus -o code --client-id=$(AZURE_CLIENT_ID) --client-secret=$(AZURE_CLIENT_SECRET) --subscription-id=$(AZURE_SUBSCRIPTION_ID) \
> pkg/helpers/azure_skus_const.go
.PHONY: build

Просмотреть файл

@ -1,46 +0,0 @@
#!/bin/bash
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.
if [ -z "$CLIENT_ID" ]; then
echo "must provide a CLIENT_ID env var"
exit 1;
fi
if [ -z "$CLIENT_SECRET" ]; then
echo "must provide a CLIENT_SECRET env var"
exit 1;
fi
if [ -z "$TENANT_ID" ]; then
echo "must provide a TENANT_ID env var"
exit 1;
fi
if [ -z "$SUBSCRIPTION_ID" ]; then
echo "must provide a SUBSCRIPTION_ID env var"
exit 1;
fi
az login --service-principal \
--username "${CLIENT_ID}" \
--password "${CLIENT_SECRET}" \
--tenant "${TENANT_ID}" &>/dev/null
# set to the sub id we want to cleanup
az account set -s "$SUBSCRIPTION_ID"
./bin/aks-engine get-locations -o code --client-id="${CLIENT_ID}" --client-secret="${CLIENT_SECRET}" --subscription-id="${SUBSCRIPTION_ID}" \
> pkg/helpers/azure_locations.go
./bin/aks-engine get-skus -o code --client-id="${CLIENT_ID}" --client-secret="${CLIENT_SECRET}" --subscription-id="${SUBSCRIPTION_ID}" \
> pkg/helpers/azure_skus_const.go
git status | grep pkg/helpers/azure
exit_code=$?
if [ $exit_code -gt "0" ]; then
echo "No modifications found! Exiting 0"
exit 0
else
echo "File was modified! Exiting 1"
exit 1
fi

Просмотреть файл

@ -24,6 +24,3 @@ test-functional: test-kubernetes
test-kubernetes: ginkgoBuild
make -C ./test/e2e build
@ORCHESTRATOR=kubernetes bash -c 'pgrep ssh-agent || eval `ssh-agent` && ./test/e2e/bin/e2e-runner'
test-azure-constants:
./scripts/azure-const.sh