Rebalance portfolios #150
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
name: Build | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v2 | |
- name: Restore NPM cache | |
uses: actions/cache@v2 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install NPM packages | |
run: yarn install | |
- name: Run tests | |
run: yarn test | |
build: | |
name: Build | |
if: github.event_name == 'push' | |
needs: test | |
runs-on: ubuntu-latest | |
outputs: | |
tag: ${{ steps.prep.outputs.tag }} | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v2 | |
- name: Prepare | |
id: prep | |
run: echo "::set-output name=tag::ghcr.io/nicwortel/indexfondsenvergelijken.nl:${GITHUB_SHA::8}" | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to GitHub Packages Docker Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Pull Docker images | |
run: docker-compose pull | |
- name: Restore Docker layer cache | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Build and push the Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
tags: | | |
ghcr.io/nicwortel/indexfondsenvergelijken.nl:latest | |
${{ steps.prep.outputs.tag }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache | |
deploy: | |
name: Deploy | |
if: github.event_name == 'push' | |
needs: [test, build] | |
runs-on: ubuntu-latest | |
environment: | |
name: production | |
url: https://www.indexfondsenvergelijken.nl | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v2 | |
- name: Set the Kubernetes context | |
uses: azure/k8s-set-context@v1 | |
with: | |
method: service-account | |
k8s-url: ${{ secrets.KUBERNETES_CLUSTER_URL }} | |
k8s-secret: ${{ secrets.KUBERNETES_SECRET }} | |
- name: Deploy to the Kubernetes cluster | |
uses: azure/k8s-deploy@v1 | |
with: | |
namespace: indexfondsenvergelijken | |
manifests: | | |
kubernetes/deployment.yaml | |
images: | | |
${{ needs.build.outputs.tag }} |