Skip to content

Merge pull request #15 from navikt/oppdaterer-cron-schedule-for-kjøring #42

Merge pull request #15 from navikt/oppdaterer-cron-schedule-for-kjøring

Merge pull request #15 from navikt/oppdaterer-cron-schedule-for-kjøring #42

name: Deploy innholdsmengde_dashboard to prod gcp
on:
push:
branches:
- main
env:
docker_image: ghcr.io/navikt/innholdsoversikt-dashboard:${{ github.sha }}
jobs:
build:
name: Build, cache and push Docker container
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Cache requirements
uses: actions/cache@v3
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/main.txt') }}
restore-keys: |
${{ env.pythonLocation }}
- if: steps.cache.outputs.cache-hit != 'true'
name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements/main.txt
- name: Login to Github Container Registry GHCR
id: login-ghcr
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: network=host
- name: Build and push image
uses: docker/build-push-action@v3
env:
REGISTRY: "${{ steps.login-ghcr.outputs.registry }}/"
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
file: Dockerfile
push: true
cache-from: type=gha,scope=${{ github.workflow }}
cache-to: type=gha,scope=${{ github.workflow }},mode=max
tags: ${{ env.docker_image }}
deploy:
name: Deploy to NAIS
needs: build
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-gcp
RESOURCE: nais.yaml
VAR: image=${{ env.docker_image }}