Redeploy #74
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
name: Build Docker images | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout master | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: daanvm | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push daanvm.nl-nginx | |
id: docker_build_daanvm_nl_nginx | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./Dockerfile-nginx | |
push: true | |
tags: daanvm/daanvm.nl-nginx:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Build and push daanvm.nl-php | |
id: docker_build_daanvm_nl_php | |
uses: docker/build-push-action@v3 | |
with: | |
context: ./ | |
file: ./Dockerfile-php | |
push: true | |
tags: daanvm/daanvm.nl-php:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
deploy-kubernetes: | |
name: Create Kubernetes resources | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout master | |
uses: actions/checkout@v3 | |
- name: Install doctl | |
uses: digitalocean/action-doctl@v2 | |
with: | |
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | |
- name: Save DigitalOcean kubeconfig with short-lived credentials | |
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 k8s-daanvm | |
- name: Create kubernetes resources | |
run: | | |
kubectl apply -f daanvm.nl.yaml | |
- name: Deploy new latest version of docker image | |
run: | | |
kubectl rollout restart deployment daanvm-nl | |
kubectl rollout restart deployment daanvm-nl-php |