Merge pull request #2 from KarmaComputing/1-github-runner-manages-remote #9
This file contains hidden or 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: Run kubectl against remote cluster | ||
| on: | ||
| workflow_dispatch: # Allows manual start of workflows | ||
| push: | ||
| branches: | ||
| - "1-github-runner-manages-remote" | ||
| paths-ignore: | ||
| - *.md | ||
| - *.example | ||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Install kubectl | ||
| run: | | ||
| mkdir $HOME/bin | ||
| curl -Lf "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" -o $HOME/bin/kubectl | ||
| chmod +x $HOME/bin/kubectl | ||
| echo "$HOME/bin" >> $GITHUB_PATH | ||
| - name: Check kubectl is available on PATH | ||
| run: kubectl version --client | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v4 | ||
| - name: Set kubeconfig with kubectl | ||
| run: | | ||
| kubectl config set-cluster "${{ vars.KUBE_REMOTE_CLUSTER }}" --server "${{ secrets.KUBE_API_SERVER_ADDR }}" | ||
| kubectl config set-credentials "${{ vars.KUBE_REMOTE_USER }}" --token "${{ secrets.KUBE_JWT_AUTH_TOKEN }}" | ||
| kubectl config set-context "${{ vars.KUBE_REMOTE_CONTEXT }}" --cluster "${{ vars.KUBE_REMOTE_CLUSTER }}" --user "${{ vars.KUBE_REMOTE_USER }}" | ||
| kubectl config use-context "${{ vars.KUBE_REMOTE_CONTEXT }}" | ||
| - name: Run kubectl command against remote API | ||
| run: kubectl get namespaces | ||
| - name: kubectl apply with a file | ||
| run: kubectl apply -f "${GITHUB_WORKSPACE}/manifests/nginx-test.yml" | ||