diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..fa64978 --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -0,0 +1,36 @@ +name: Build and Deploy + +on: + push: + branches: [main] + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + container: + image: quay.io/buildah/stable + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build image + run: | + IMAGE=harbor.scottyah.com/scottyah/blog + buildah bud -t $IMAGE:${{ github.sha }} -t $IMAGE:latest . + + - name: Push image + run: | + IMAGE=harbor.scottyah.com/scottyah/blog + buildah login -u "${{ secrets.HARBOR_USERNAME }}" -p "${{ secrets.HARBOR_PASSWORD }}" harbor.scottyah.com + buildah push $IMAGE:${{ github.sha }} + buildah push $IMAGE:latest + + - name: Deploy + run: | + curl -LO "https://dl.k8s.io/release/$(curl -Ls https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" + chmod +x kubectl + mkdir -p ~/.kube + echo "${{ secrets.KUBECONFIG_DATA }}" | base64 -d > ~/.kube/config + sed -i "s|harbor.scottyah.com/scottyah/blog:latest|harbor.scottyah.com/scottyah/blog:${{ github.sha }}|" k8s.yaml + ./kubectl apply -f k8s.yaml + ./kubectl rollout status deployment/blog-dep -n blog --timeout=120s