Azure / k8s-deploy

GitHub Action for deploying to Kubernetes clusters
MIT License
255 stars 104 forks source link

Bug: manifests path set using Environment variables throw error "no such file or directory, lstat '$FOLDER/k8s/deploy" #278

Closed ezYakaEagle442 closed 1 year ago

ezYakaEagle442 commented 1 year ago

What happened?

See my workflow

  PRJ_PREFIX: spring-petclinic

  API_GATEWAY: api-gateway
  ADMIN_SERVER: admin-server
  CUSTOMERS_SERVICE: customers-service
  VETS_SERVICE: vets-service
  VISITS_SERVICE: visits-service

  CONFIG_SERVER: config-server
  DISCOVERY_SERVER: discovery-server

    - name: Set Base environment variables
      run: |
        echo "ADMIN_SERVER_FOLDER=${{ env.PRJ_PREFIX }}-${{ env.ADMIN_SERVER }}" >> $GITHUB_ENV
        echo "DISCOVERY_SERVER_FOLDER=${{ env.PRJ_PREFIX }}-${{ env.DISCOVERY_SERVER }}" >> $GITHUB_ENV

        echo "API_GATEWAY_FOLDER=${{ env.PRJ_PREFIX }}-${{ env.API_GATEWAY }}" >> $GITHUB_ENV
        echo "CONFIG_SERVER_FOLDER=${{ env.PRJ_PREFIX }}-${{ env.CONFIG_SERVER }}" >> $GITHUB_ENV
        echo "CUSTOMERS_SERVICE_FOLDER=${{ env.PRJ_PREFIX }}-${{ env.CUSTOMERS_SERVICE }}" >> $GITHUB_ENV
        echo "VETS_SERVICE_FOLDER=${{ env.PRJ_PREFIX }}-${{ env.VETS_SERVICE }}" >> $GITHUB_ENV
        echo "VISITS_SERVICE_FOLDER=${{ env.PRJ_PREFIX }}-${{ env.VISITS_SERVICE }}" >> $GITHUB_ENV

      shell: bash

    - name: Deploy Manifests to AKS
      uses: Azure/k8s-deploy@v4
      with:
        namespace: ${{ env.PETCLINIC_NAMESPACE }}
        manifests: |
            $CONFIG_SERVER_FOLDER/k8s/deploy
            $VETS_SERVICE_FOLDER/k8s/deploy
            $CUSTOMERS_SERVICE_FOLDER/k8s/deploy
            $VISITS_SERVICE_FOLDER/k8s/deploy
            $API_GATEWAY_FOLDER/k8s/deploy

Version

Runner

GH public Runner

Relevant log output

https://github.com/ezYakaEagle442/aks-java-petclinic-mic-srv/actions/runs/3969180670/jobs/6803319810

Checking GITHUB_ENV

ADMIN_SERVER_FOLDER=spring-petclinic-admin-server
DISCOVERY_SERVER_FOLDER=spring-petclinic-discovery-server
API_GATEWAY_FOLDER=spring-petclinic-api-gateway
CONFIG_SERVER_FOLDER=spring-petclinic-config-server
CUSTOMERS_SERVICE_FOLDER=spring-petclinic-customers-service
VETS_SERVICE_FOLDER=spring-petclinic-vets-service
VISITS_SERVICE_FOLDER=spring-petclinic-visits-service
GH_WORKSPACE=/home/runner/work/aks-java-petclinic-mic-srv/aks-java-petclinic-mic-srv

Cheking folder  spring-petclinic-api-gateway
total 24
drwxr-xr-x 3 runner docker 4096 Jan 20 15:53 .
drwxr-xr-x 4 runner docker 4096 Jan 20 15:53 ..
drwxr-xr-x 2 runner docker 4096 Jan 20 15:53 deploy
-rw-r--r-- 1 runner docker  616 Jan 20 15:53 petclinic-ui-cluster-ip.yaml
-rw-r--r-- 1 runner docker 2100 Jan 20 15:53 petclinic-ui-deployment.yaml
-rw-r--r-- 1 runner docker  291 Jan 20 15:53 petclinic-ui-ingress.yaml
Cheking folder  spring-petclinic-customers-service
total 24
drwxr-xr-x 3 runner docker 4096 Jan 20 15:53 .
drwxr-xr-x 4 runner docker 4096 Jan 20 15:53 ..
drwxr-xr-x 2 runner docker 4096 Jan 20 15:53 deploy
-rw-r--r-- 1 runner docker 3534 Jan 20 15:53 petclinic-customer-deployment.yaml
-rw-r--r-- 1 runner docker  697 Jan 20 15:53 petclinic-customer-ingress.yaml
-rw-r--r-- 1 runner docker  630 Jan 20 15:53 petclinic-customer-srv-cluster-ip.yaml
Cheking folder  spring-petclinic-vets-service
total 24
drwxr-xr-x 3 runner docker 4096 Jan 20 15:53 .
drwxr-xr-x 4 runner docker 4096 Jan 20 15:53 ..
drwxr-xr-x 2 runner docker 4096 Jan 20 15:53 deploy
-rw-r--r-- 1 runner docker 3519 Jan 20 15:53 petclinic-vet-deployment.yaml
-rw-r--r-- 1 runner docker  307 Jan 20 15:53 petclinic-vet-ingress.yaml
-rw-r--r-- 1 runner docker  620 Jan 20 15:53 petclinic-vet-srv-cluster-ip.yaml
Cheking folder  spring-petclinic-visits-service
total 24
drwxr-xr-x 3 runner docker 4096 Jan 20 15:53 .
drwxr-xr-x 4 runner docker 4096 Jan 20 15:53 ..
drwxr-xr-x 2 runner docker 4096 Jan 20 15:53 deploy
-rw-r--r-- 1 runner docker 3538 Jan 20 15:53 petclinic-visits-deployment.yaml
-rw-r--r-- 1 runner docker  313 Jan 20 15:53 petclinic-visits-ingress.yaml
-rw-r--r-- 1 runner docker  624 Jan 20 15:53 petclinic-visits-srv-cluster-ip.yaml
Cheking folder  spring-petclinic-config-server
total 28
drwxr-xr-x 3 runner docker 4096 Jan 20 15:53 .
drwxr-xr-x 4 runner docker 4096 Jan 20 15:53 ..
drwxr-xr-x 2 runner docker 4096 Jan 20 15:53 deploy
-rw-r--r-- 1 runner docker  [179](https://github.com/ezYakaEagle442/aks-java-petclinic-mic-srv/actions/runs/3969180670/jobs/6803319810#step:7:180) Jan 20 15:53 petclinic-config-server-cm.yaml
-rw-r--r-- 1 runner docker 2212 Jan 20 15:53 petclinic-config-server-deployment.yaml
-rw-r--r-- 1 runner docker  326 Jan 20 15:53 petclinic-config-server-ingress.yaml
-rw-r--r-- 1 runner docker  704 Jan 20 15:53 petclinic-config-server-srv-cluster-ip.yaml
Cheking folder  spring-petclinic-api-gateway
total 20
drwxr-xr-x 2 runner docker 4096 Jan 20 15:53 .
drwxr-xr-x 3 runner docker 4096 Jan 20 15:53 ..
-rw-r--r-- 1 runner docker  615 Jan 20 15:53 petclinic-ui-cluster-ip.yaml
-rw-r--r-- 1 runner docker 2089 Jan 20 15:53 petclinic-ui-deployment.yaml
-rw-r--r-- 1 runner docker  321 Jan 20 15:53 petclinic-ui-ingress.yaml
Cheking folder  spring-petclinic-customers-service
total 20
drwxr-xr-x 2 runner docker 4096 Jan 20 15:53 .
drwxr-xr-x 3 runner docker 4096 Jan 20 15:53 ..
-rw-r--r-- 1 runner docker 3523 Jan 20 15:53 petclinic-customer-deployment.yaml
-rw-r--r-- 1 runner docker  727 Jan 20 15:53 petclinic-customer-ingress.yaml
-rw-r--r-- 1 runner docker  629 Jan 20 15:53 petclinic-customer-srv-cluster-ip.yaml
Cheking folder  spring-petclinic-vets-service
total 20
drwxr-xr-x 2 runner docker 4096 Jan 20 15:53 .
drwxr-xr-x 3 runner docker 4096 Jan 20 15:53 ..
-rw-r--r-- 1 runner docker 3508 Jan 20 15:53 petclinic-vet-deployment.yaml
-rw-r--r-- 1 runner docker  337 Jan 20 15:53 petclinic-vet-ingress.yaml
-rw-r--r-- 1 runner docker  619 Jan 20 15:53 petclinic-vet-srv-cluster-ip.yaml
Cheking folder  spring-petclinic-visits-service
total 20
drwxr-xr-x 2 runner docker 4096 Jan 20 15:53 .
drwxr-xr-x 3 runner docker 4096 Jan 20 15:53 ..
-rw-r--r-- 1 runner docker 3527 Jan 20 15:53 petclinic-visits-deployment.yaml
-rw-r--r-- 1 runner docker  343 Jan 20 15:53 petclinic-visits-ingress.yaml
-rw-r--r-- 1 runner docker  623 Jan 20 15:53 petclinic-visits-srv-cluster-ip.yaml
Cheking folder  spring-petclinic-config-server
total 24
drwxr-xr-x 2 runner docker 4096 Jan 20 15:53 .
drwxr-xr-x 3 runner docker 4096 Jan 20 15:53 ..
-rw-r--r-- 1 runner docker  179 Jan 20 15:53 petclinic-config-server-cm.yaml
-rw-r--r-- 1 runner docker 2[201](https://github.com/ezYakaEagle442/aks-java-petclinic-mic-srv/actions/runs/3969180670/jobs/6803319810#step:7:202) Jan 20 15:53 petclinic-config-server-deployment.yaml
-rw-r--r-- 1 runner docker  356 Jan 20 15:53 petclinic-config-server-ingress.yaml
-rw-r--r-- 1 runner docker  703 Jan 20 15:53 petclinic-config-server-srv-cluster-ip.yaml

Error: Error: Exception occurred while reading the file $CONFIG_SERVER_FOLDER/k8s/deploy: Error: ENOENT: no such file or directory, lstat '$CONFIG_SERVER_FOLDER/k8s/deploy'
ezYakaEagle442 commented 1 year ago

The error does not happen when I hard code the Manifests paths :

- name: Deploy Manifests to AKS
  uses: Azure/k8s-deploy@v4
  with:
    namespace: ${{ env.PETCLINIC_NAMESPACE }}
    manifests: |
        spring-petclinic-config-server/k8s/deploy
        spring-petclinic-vets-service/k8s/deploy
        spring-petclinic-customers-service/k8s/deploy
        spring-petclinic-visits-service/k8s/deploy
OliverMKing commented 1 year ago

This syntax is not valid in GitHub workflows. This wouldn't work with any action.

You should be using something like

- run: echo ::set-output name=server_folder::${{ env.PRJ_PREFIX }}-${{ env.CONFIG_SERVER }}
   id: variables
- name: Deploy Manifests
  uses: Azure/k8s-deploy@v4
  with:
    namespace: ${{ env.PETCLINIC_NAMESPACE }}
    manifests: |
        ${{ steps.variables.outputs.server_folder }}/k8s/deploy

Here's a related discussion with more examples.

OliverMKing commented 1 year ago

Going to close this now. Feel free to reopen.