-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #257 from norcalipa/norcalipa/refactor-actions
Refactoring deployment workflows
- Loading branch information
Showing
6 changed files
with
86 additions
and
21 deletions.
There are no files selected for viewing
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
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
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
2 changes: 1 addition & 1 deletion
2
.github/workflows/coverage.yml → .github/workflows/tests-with-coverage.yml
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright (c) 2024 Isaac Adams | ||
# Licensed under the MIT License. See LICENSE file in the project root for full license information. | ||
name: Update Deployment (prod) | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- '**' | ||
- '!.github/workflows/update-home-deployment.yml' | ||
- '!k8s/deployment.yml' | ||
|
||
concurrency: | ||
group: deployment | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
deploy-home-k3s: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
|
||
- name: Get latest commit SHA from main branch | ||
id: get-sha | ||
run: echo "GITHUB_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- 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: | | ||
# Copy deployment.yml to the remote system | ||
scp -o ProxyCommand='cloudflared access ssh --hostname %h' -o StrictHostKeyChecking=no ./k8s/deployment.yml ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:/tmp/deployment.yml | ||
# Apply the copied deployment.yml | ||
ssh -o ProxyCommand='cloudflared access ssh --hostname %h' -o StrictHostKeyChecking=no ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} <<EOF | ||
export GITHUB_SHA=${{ env.GITHUB_SHA }} | ||
envsubst < /tmp/deployment.yml | k3s kubectl apply -f - | ||
EOF |
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