Skip to content

Commit

Permalink
hetzner cloud github deployment workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinyanakiev committed Aug 16, 2024
1 parent 41ee607 commit b14face
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/build-deploy-k8s-dev-hetzner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Build, Migrate & Deploy to Dev on Hetzner

on:
push:
branches: [develop]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/[email protected]

- name: 'Login into ACR'
uses: azure/docker-login@v2
with:
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: 'Build & Push image'
run: |
docker build -f Dockerfile . -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/alkemio-virtual-contributor-ingest-space:${{ github.sha }} -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/alkemio-virtual-contributor-ingest-space:latest
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/alkemio-virtual-contributor-ingest-space:${{ github.sha }}
deploy:
runs-on: ubuntu-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/[email protected]

- name: Install Kubectl
uses: azure/[email protected]
with:
version: 'v1.27.6' # Ensure this matches the version used in your cluster

- name: Set up Kubeconfig for Hetzner k3s
run: |
mkdir -p $HOME/.kube # Ensure the .kube directory exists
echo "${{ secrets.KUBECONFIG_SECRET_HETZNER_DEV }}" > $HOME/.kube/config
chmod 600 $HOME/.kube/config
- name: Create Image Pull Secret
run: |
kubectl create secret docker-registry alkemio-virtual-contributor-ingest-space-secret \
--docker-server=${{ secrets.REGISTRY_LOGIN_SERVER }} \
--docker-username=${{ secrets.REGISTRY_USERNAME }} \
--docker-password=${{ secrets.REGISTRY_PASSWORD }} \
--dry-run=client -o yaml | kubectl apply -f -
- uses: Azure/[email protected]
with:
manifests: |
manifests/25-virtual-contributor-ingest-space-deployment-dev.yml
images: |
${{ secrets.REGISTRY_LOGIN_SERVER }}/alkemio-virtual-contributor-ingest-space:${{ github.sha }}
imagepullsecrets: |
alkemio-virtual-contributor-ingest-space-secret
57 changes: 57 additions & 0 deletions .github/workflows/build-deploy-k8s-sandbox-hetzner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build, Migrate & Deploy to Sandbox on Hetzner

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/[email protected]

- name: 'Login into ACR'
uses: azure/docker-login@v2
with:
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: 'Build & Push image'
run: |
docker build -f Dockerfile . -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/alkemio-virtual-contributor-ingest-space:${{ github.sha }} -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/alkemio-virtual-contributor-ingest-space:latest
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/alkemio-virtual-contributor-ingest-space:${{ github.sha }}
deploy:
runs-on: ubuntu-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/[email protected]

- name: Install Kubectl
uses: azure/[email protected]
with:
version: 'v1.27.6' # Ensure this matches the version used in your cluster

- name: Set up Kubeconfig for Hetzner k3s
run: |
mkdir -p $HOME/.kube # Ensure the .kube directory exists
echo "${{ secrets.KUBECONFIG_SECRET_HETZNER_SANDBOX }}" > $HOME/.kube/config
chmod 600 $HOME/.kube/config
- name: Create Image Pull Secret
run: |
kubectl create secret docker-registry alkemio-virtual-contributor-ingest-space-secret \
--docker-server=${{ secrets.REGISTRY_LOGIN_SERVER }} \
--docker-username=${{ secrets.REGISTRY_USERNAME }} \
--docker-password=${{ secrets.REGISTRY_PASSWORD }} \
--dry-run=client -o yaml | kubectl apply -f -
- uses: Azure/[email protected]
with:
manifests: |
manifests/25-virtual-contributor-ingest-space-deployment-dev.yml
images: |
${{ secrets.REGISTRY_LOGIN_SERVER }}/alkemio-virtual-contributor-ingest-space:${{ github.sha }}
imagepullsecrets: |
alkemio-virtual-contributor-ingest-space-secret

0 comments on commit b14face

Please sign in to comment.