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

66 lines
2.4 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 16:40:39 +00:00
docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD
2019-09-07 16:41:57 +00:00
docker build . -t xena/christinewebsite:$(echo $GITHUB_SHA | head -c7)
docker push xena/christinewebsite:$(echo $GITHUB_SHA | head -c7)
2019-09-07 16:40:39 +00:00
env:
DOCKER_USERNAME: "xena"
DOCKER_PASSWORD: "${{ secrets.DOCKER_PASSWORD }}"
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
2019-09-07 16:45:08 +00:00
mkdir -p ~/.config/dyson
2019-09-07 15:50:47 +00:00
echo '[DigitalOcean]
Token = ""
[Cloudflare]
Email = ""
Token = ""
[Secrets]
GitCheckout = "./within-terraform-secret"' > ~/.config/dyson/dyson.ini
2019-09-07 16:45:08 +00:00
2019-09-07 16:48:06 +00:00
./dyson manifest \
2019-09-07 15:50:47 +00:00
--name=christinewebsite \
--domain=christine.website \
2019-09-07 16:12:04 +00:00
--dockerImage=xena/christinewebsite:$(echo $GITHUB_SHA | head -c7) \
2019-09-07 15:50:47 +00:00
--containerPort=5000 \
--replicas=1 \
--useProdLE=true > deploy.yml
2019-09-07 17:34:00 +00:00
- name: Configure/Deploy/Verify Kubernetes
2019-09-07 17:23:10 +00:00
run: |
2019-09-07 17:28:08 +00:00
curl -L https://github.com/digitalocean/doctl/releases/download/v1.30.0/doctl-1.30.0-linux-amd64.tar.gz | tar xz
2019-09-07 17:39:36 +00:00
./doctl auth init -t $DIGITALOCEAN_ACCESS_TOKEN
2019-09-07 17:34:00 +00:00
./doctl kubernetes cluster kubeconfig show kubermemes > .kubeconfig
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
chmod +x kubectl
2019-09-07 20:06:37 +00:00
./kubectl --kubeconfig .kubeconfig apply -n apps -f deploy.yml
2019-09-07 17:34:00 +00:00
sleep 2
2019-09-07 20:06:37 +00:00
./kubectl --kubeconfig .kubeconfig rollout -n apps status deployment/christinewebsite
2019-09-07 16:59:26 +00:00
env:
2019-09-07 17:05:08 +00:00
DIGITALOCEAN_ACCESS_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }}