|
| 1 | +name: 'K8: Restart' |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + deployment_name: |
| 7 | + description: 'Deployment Name' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +# Special permissions required for OIDC authentication |
| 12 | +permissions: |
| 13 | + id-token: write |
| 14 | + contents: read |
| 15 | + actions: read |
| 16 | + |
| 17 | +jobs: |
| 18 | + k8-restart: |
| 19 | + name: 'K8: Restart' |
| 20 | + runs-on: [self-hosted, dev] |
| 21 | + environment: dev |
| 22 | + env: |
| 23 | + KUBELOGIN_VERSION: "v0.0.25" |
| 24 | + KUBERNETES_CLUSTER_NAME: "${{ vars.KUBERNETES_CLUSTER_NAME }}" |
| 25 | + KUBERNETES_NAMESPACE: "${{ vars.KUBERNETES_NAMESPACE }}" |
| 26 | + AZURE_RESOURCE_GROUP: "${{ vars.AZURE_RESOURCE_GROUP }}" |
| 27 | + steps: |
| 28 | + # Checkout the repository to the GitHub Actions runner |
| 29 | + - name: Checkout |
| 30 | + uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: GitHub Configuration |
| 33 | + run: git config --global url."https://oauth2:${{ secrets.GH_TOKEN }}@github.com".insteadOf https://github.com |
| 34 | + |
| 35 | + - name: Clone cicd-deployment-scripts |
| 36 | + run: git clone https://github.com/code-kern-ai/cicd-deployment-scripts.git |
| 37 | + |
| 38 | + # Install the latest version of Kubernetes CLI and configure the Kubernetes CLI configuration file with a Kubernetes Cloud user API token |
| 39 | + - name: Azure Cloud Login |
| 40 | + uses: azure/login@v2 |
| 41 | + with: |
| 42 | + client-id: ${{ secrets.AZURE_CLIENT_ID }} |
| 43 | + tenant-id: ${{ secrets.AZURE_TENANT_ID }} |
| 44 | + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} |
| 45 | + |
| 46 | + # Use kubelogin to configure your kubeconfig for Azure auth |
| 47 | + - name: Set up kubelogin for non-interactive login |
| 48 | + uses: azure/use-kubelogin@v1 |
| 49 | + with: |
| 50 | + kubelogin-version: ${{ env.KUBELOGIN_VERSION }} |
| 51 | + |
| 52 | + - uses: azure/aks-set-context@v3 |
| 53 | + with: |
| 54 | + resource-group: ${{ env.AZURE_RESOURCE_GROUP }} |
| 55 | + cluster-name: ${{ env.KUBERNETES_CLUSTER_NAME }} |
| 56 | + admin: 'false' |
| 57 | + use-kubelogin: 'true' |
| 58 | + |
| 59 | + - name: Run Restart |
| 60 | + shell: bash |
| 61 | + run: | |
| 62 | + bash cicd-deployment-scripts/k8s/restart.sh \ |
| 63 | + -n ${{ env.KUBERNETES_NAMESPACE }} \ |
| 64 | + -d ${{ inputs.deployment_name }} |
0 commit comments