Deploy to Kubernetes (prod) #14
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: Deploy to Kubernetes on Fats | |
env: | |
GITHUB_SHA: ${{ github.sha }} | |
on: | |
pull_request: | |
types: | |
- closed | |
branches: | |
- main | |
workflow_run: | |
workflows: [ "Build Image" ] | |
types: | |
- completed | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up SSH | |
uses: webfactory/ssh-agent@v0.5.3 | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Install Cloudflared | |
run: | | |
sudo mkdir -p --mode=0755 /usr/share/keyrings | |
curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg | sudo tee /usr/share/keyrings/cloudflare-main.gpg >/dev/null | |
# Add this repo to your apt repositories | |
echo 'deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared jammy main' | sudo tee /etc/apt/sources.list.d/cloudflared.list | |
# install cloudflared | |
sudo apt-get update && sudo apt-get install cloudflared | |
- name: Deploy to Kubernetes | |
run: | | |
#cloudflared tunnel --hostname ${SSH_HOST} --url ssh://${SSH_HOST} | |
ssh -o ProxyCommand='cloudflared access ssh --hostname %h' -o StrictHostKeyChecking=no ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} <<EOF | |
k0s kubectl apply -f deployment.yml | |
EOF |