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

69 lines
2.3 KiB
YAML
Raw Normal View History

2019-09-07 15:44:38 +00:00
name: "CI/CD"
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
2019-09-07 15:50:47 +00:00
- name: Build/Push Docker Image
2019-09-07 15:44:38 +00:00
run: |
2019-09-07 15:59:57 +00:00
mkdir -p ~/.docker
echo $DOCKER_CONFIG | base64 -d > ~/.docker/config
md5sum ~/.docker/config
2019-09-07 16:04:40 +00:00
docker build . -t xena/christine.website:$(echo $GITHUB_SHA | head -c7)
2019-09-07 15:44:38 +00:00
docker push xena/christine.website:$(echo $GITHUB_SHA | head -c7)
env:
2019-09-07 15:50:47 +00:00
DOCKER_CONFIG: "$${ secrets.DOCKER_CONFIG }"
2019-09-07 15:44:38 +00:00
- name: Download secrets
2019-09-07 15:50:47 +00:00
run: |
mkdir ~/.ssh
2019-09-07 15:59:57 +00:00
echo $FILE_DATA | base64 -d > ~/.ssh/id_rsa
2019-09-07 15:50:47 +00:00
md5sum ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
git clone git@git.xeserv.us:xena/within-terraform-secret
2019-09-07 15:44:38 +00:00
env:
2019-09-07 15:50:47 +00:00
FILE_DATA: ${{ secrets.SSH_PRIVATE_KEY }}
2019-09-07 15:44:38 +00:00
GIT_SSH_COMMAND: "ssh -i ~/.ssh/id_rsa -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
2019-09-07 15:50:47 +00:00
- name: Install/Configure/Use Dyson
2019-09-07 15:44:38 +00:00
run: |
2019-09-07 15:50:47 +00:00
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
2019-09-07 15:44:38 +00:00
- name: Configure Kubernetes
uses: digitalocean/action-doctl@v1.3.0
2019-09-07 15:55:21 +00:00
with:
entrypoint: /usr/local/bin/doctl
args: kubernetes cluster kubeconfig show kubermemes > $HOME/.kubeconfig
2019-09-07 15:44:38 +00:00
- name: Deploy
uses: docker://lachlanevenson/k8s-kubectl
2019-09-07 15:55:21 +00:00
with:
entrypoint: /usr/local/bin/kubectl
args: |
2019-09-07 16:04:02 +00:00
--kubeconfig=$HOME/.kubeconfig apply -f deploy.yml
2019-09-07 15:55:21 +00:00
- name: Verify
uses: docker://lachlanevenson/k8s-kubectl
with:
entrypoint: /usr/local/bin/kubectl
args: |
--kubeconfig=$HOME/.kubeconfig rollout status deployment/christinewebsite