|
| 1 | +name: Build, Migrate & Deploy to Sandbox on Hetzner |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + build: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + steps: |
| 10 | + - name: 'Checkout GitHub Action' |
| 11 | + |
| 12 | + |
| 13 | + - name: 'Login into ACR' |
| 14 | + uses: azure/docker-login@v2 |
| 15 | + with: |
| 16 | + login-documentation: ${{ secrets.REGISTRY_LOGIN_SERVER }} |
| 17 | + username: ${{ secrets.REGISTRY_USERNAME }} |
| 18 | + password: ${{ secrets.REGISTRY_PASSWORD }} |
| 19 | + |
| 20 | + - name: 'Build & Push image' |
| 21 | + run: | |
| 22 | + docker build -f Dockerfile . -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/alkemio-documentation:${{ github.sha }} -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/alkemio-documentation:latest |
| 23 | + docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/alkemio-documentation:${{ github.sha }} |
| 24 | +
|
| 25 | + deploy: |
| 26 | + needs: build |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - name: 'Checkout GitHub Action' |
| 30 | + |
| 31 | + |
| 32 | + - name: Install Kubectl |
| 33 | + |
| 34 | + with: |
| 35 | + version: 'v1.27.6' # Ensure this matches the version used in your cluster |
| 36 | + |
| 37 | + - name: Set up Kubeconfig for Hetzner k3s |
| 38 | + run: | |
| 39 | + mkdir -p $HOME/.kube # Ensure the .kube directory exists |
| 40 | + echo "${{ secrets.KUBECONFIG_SECRET_HETZNER_SANDBOX }}" > $HOME/.kube/config |
| 41 | + chmod 600 $HOME/.kube/config |
| 42 | +
|
| 43 | + - name: Create Image Pull Secret |
| 44 | + run: | |
| 45 | + kubectl create secret docker-registry alkemio-documentation-secret \ |
| 46 | + --docker-documentation=${{ secrets.REGISTRY_LOGIN_SERVER }} \ |
| 47 | + --docker-username=${{ secrets.REGISTRY_USERNAME }} \ |
| 48 | + --docker-password=${{ secrets.REGISTRY_PASSWORD }} \ |
| 49 | + --dry-run=client -o yaml | kubectl apply -f - |
| 50 | +
|
| 51 | + - name: Deploy to k3s on Hetzner |
| 52 | + |
| 53 | + with: |
| 54 | + manifests: | |
| 55 | + manifests/25-documentation-deployment-dev.yaml |
| 56 | + images: | |
| 57 | + ${{ secrets.REGISTRY_LOGIN_SERVER }}/alkemio-documentation:${{ github.sha }} |
| 58 | + imagepullsecrets: | |
| 59 | + alkemio-documentation-secret |
0 commit comments