diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 1c09d87..3f6e543 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -1,16 +1,35 @@ name: "Nix" on: push: + branches: + - master jobs: - tests: + docker-build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - uses: cachix/install-nix-action@v6 - - uses: cachix/cachix-action@v3 - with: - name: xe - - run: | - nix-build docker.nix - docker load -i result - docker tag xena/christinewebsite:latest xena/christinewebsite:$(echo $GITHUB_SHA | head -c7) + - uses: actions/checkout@v1 + - uses: cachix/install-nix-action@v6 + - uses: cachix/cachix-action@v3 + with: + name: xe + signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - run: | + nix-build docker.nix + docker load -i result + docker tag xena/christinewebsite:latest xena/christinewebsite:$GITHUB_SHA + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin + docker push xena/christinewebsite + env: + DOCKER_USERNAME: "xena" + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + release: + runs-on: ubuntu-latest + needs: docker-build + if: github.ref == 'refs/heads/master' + steps: + - uses: cachix/install-nix-action@v6 + - name: deploy + run: ./scripts/release.sh + env: + DIGITALOCEAN_ACCESS_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }} diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index a3df3e3..0000000 --- a/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM xena/go:1.14 AS build -ENV GOPROXY https://cache.greedo.xeserv.us -COPY . /site -WORKDIR /site -RUN CGO_ENABLED=0 go test -v ./... -RUN CGO_ENABLED=0 GOBIN=/root go install -v ./cmd/site - -FROM xena/alpine -EXPOSE 5000 -WORKDIR /site -COPY --from=build /root/site . -COPY ./static /site/static -COPY ./templates /site/templates -COPY ./blog /site/blog -COPY ./talks /site/talks -COPY ./gallery /site/gallery -COPY ./css /site/css -COPY ./signalboost.dhall /site/signalboost.dhall -HEALTHCHECK CMD wget --spider http://127.0.0.1:5000/.within/health || exit 1 -CMD ./site diff --git a/scripts/docker.sh b/scripts/docker.sh deleted file mode 100755 index bb9d91a..0000000 --- a/scripts/docker.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -set -e - -docker build -t xena/site . -exec docker run --rm -itp 5030:5000 -e PORT=5000 xena/site diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100755 index 0000000..7458012 --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env nix-shell +#! nix-shell -p doctl -p kubectl -i bash +doctl kubernetes cluster kubeconfig save kubermemes +dhall-to-yaml-ng < ./site.dhall | kubectl apply -n apps -f - +kubectl rollout status -n apps deployment/christinewebsite diff --git a/site.dhall b/site.dhall index f126d3d..7b3d3ab 100644 --- a/site.dhall +++ b/site.dhall @@ -10,12 +10,12 @@ let image = "xena/christinewebsite:${tag}" let vars : List kubernetes.EnvVar.Type - = [ kubernetes.EnvVar::{ name = "PORT", value = Some "5000" } ] + = [ kubernetes.EnvVar::{ name = "PORT", value = Some "3030" } ] in kms.app.make kms.app.Config::{ , name = "christinewebsite" - , appPort = 5000 + , appPort = 3030 , image = image , domain = "christine.website" , leIssuer = "prod"