commit e688484991ac0660b52c0cd47dccf27deafc8b5f Author: Pal Kerecsenyi Date: Sat Jan 13 23:11:50 2024 +0000 Add reusable scripts for docker build and palcloud deploy diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..174b750 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,20 @@ +on: + workflow_call: + secrets: + DOCKER_USERNAME: + required: true + DOCKER_PASSWORD: + required: true + +jobs: + build-docker-container: + runs-on: ubuntu-latest + container: docker.io/palkerecs/kaniko:alpine + steps: + - uses: actions/checkout@v3 + - run: apk add skopeo + name: Instal authentication helper + - run: skopeo login --compat-auth-file /kaniko/.docker/config.json -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} gitea.palk.me + name: Login to container registry + - run: /kaniko/executor --context "${{ github.workspace }}" --dockerfile "${{ github.workspace }}/Dockerfile" --destination "gitea.palk.me/${{ github.repository }}:${{ github.sha }}" --cache=true + name: Build and publish container diff --git a/.github/workflows/palcloud-deploy.yml b/.github/workflows/palcloud-deploy.yml new file mode 100644 index 0000000..dced88d --- /dev/null +++ b/.github/workflows/palcloud-deploy.yml @@ -0,0 +1,41 @@ +on: + workflow_call: + inputs: + deployment-file: + type: string + default: k8s/deployment.yaml + secrets: + PALTIVERSE_K8S: + required: true + TAILSCALE_TOKEN: + required: true + +jobs: + deploy: + runs-on: ubuntu-latest + container: alpine:3 + steps: + - run: apk add tailscale kubectl bash curl envsubst nodejs npm git + name: Install dependencies + + - uses: actions/checkout@v3 + + - name: Create kube directory + run: mkdir /opt/kube + - name: Bootstrap kubeconfig + run: echo "$PALTIVERSE_K8S" | base64 -d > /opt/kube/config + env: + PALTIVERSE_K8S: ${{ secrets.PALTIVERSE_K8S }} + - name: Add tailscale proxy to kubeconfig + run: kubectl config set clusters.default.proxy-url http://localhost:1055 + env: + KUBECONFIG: /opt/kube/config + + - name: Configure tailscale + run: tailscaled --tun=userspace-networking --socks5-server=localhost:1055 --outbound-http-proxy-listen=localhost:1055 & tailscale up --authkey="${{ secrets.TAILSCALE_TOKEN }}" --advertise-tags=tag:gitea-runners + + - name: Run kubectl + run: envsubst < ${{ inputs.deployment-file }} | kubectl apply -f - + env: + KUBECONFIG: /opt/kube/config + CI_COMMIT_SHA: ${{ github.sha }}