site/.github/workflows/kubernetes-cd.yml

61 lines
2.0 KiB
YAML

name: "CI/CD"
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Build/Push Docker Image
run: |
docker build . -t xena/christine.website:$(echo $GITHUB_SHA | head -c7)
mkdir -p ~/.docker && echo $DOCKER_CONFIG > ~/.docker/config
docker push xena/christine.website:$(echo $GITHUB_SHA | head -c7)
env:
DOCKER_CONFIG: "$${ secrets.DOCKER_CONFIG }"
- name: Download secrets
run: |
mkdir ~/.ssh
echo $FILE_DATA > temp
cat temp | base64 -d > ~/.ssh/id_rsa
rm temp
md5sum ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
git clone git@git.xeserv.us:xena/within-terraform-secret
env:
FILE_DATA: ${{ secrets.SSH_PRIVATE_KEY }}
GIT_SSH_COMMAND: "ssh -i ~/.ssh/id_rsa -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
- name: Install/Configure/Use Dyson
run: |
curl https://xena.greedo.xeserv.us/files/dyson-linux-amd64-0.1.0.tgz | tar xz
cp ./dyson-linux-amd64-0.1.0/dyson .
rm -rf dyson-linux-amd64-0.1.0
mkdir ~/.config/dyson
echo '[DigitalOcean]
Token = ""
[Cloudflare]
Email = ""
Token = ""
[Secrets]
GitCheckout = "./within-terraform-secret"' > ~/.config/dyson/dyson.ini
dyson manifest \
--name=christinewebsite \
--domain=christine.website \
--dockerImage=xena/christine.website:$(echo $GITHUB_SHA | head -c7) \
--containerPort=5000 \
--replicas=1 \
--useProdLE=true > deploy.yml
- name: Configure Kubernetes
uses: digitalocean/action-doctl@v1.3.0
run: |
doctl kubernetes cluster kubeconfig show kubermemes > $HOME/.kubeconfig
- name: Deploy
uses: docker://lachlanevenson/k8s-kubectl
run: |
kubectl --kubeconfig=$HOME/.kubeconfig apply -f deploy.yml
kubectl --kubeconfig=$HOME/.kubeconfig rollout status deployment/christinewebsite