This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (81 loc) · 2.58 KB
/
deploy.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: "Build and deploy"
on: [workflow_dispatch, push]
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
RESOURCE: .nais/nais.yaml
permissions:
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.image.outputs.image }}
steps:
- uses: actions/checkout@v3
- name: set Docker image name:tag
id: image
run: |
export IMAGE="ghcr.io/${{ github.repository }}:$(date '+%Y-%m-%d')-$(git --no-pager log -1 --pretty=%h)"
echo "IMAGE=$IMAGE" >> $GITHUB_ENV
echo ::set-output name=image::"$IMAGE"
- uses: docker/setup-buildx-action@v2
- uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
name: Build and push
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Dockerimage
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ env.IMAGE }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- run: |
echo "Built new image! :rocket:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "${{ env.IMAGE }}" >> $GITHUB_STEP_SUMMARY
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
deploy-dev:
runs-on: ubuntu-latest
needs: build
env:
IMAGE: ${{ needs.build.outputs.image }}
steps:
- uses: actions/checkout@v3
- name: Deploy to dev
uses: nais/deploy/actions/deploy@v1
env:
CLUSTER: dev-gcp
VAR: ingress=https://data.intern.dev.nav.no/
RESOURCE: .nais/nais.yaml
deploy-prod:
runs-on: ubuntu-latest
needs: [build, deploy-dev]
env:
IMAGE: ${{ needs.build.outputs.image }}
steps:
- uses: actions/checkout@v3
- name: Deploy to prod
if: github.ref == 'refs/heads/main'
uses: nais/deploy/actions/deploy@v1
env:
CLUSTER: prod-gcp
VAR: ingress=https://data.intern.nav.no/
RESOURCE: .nais/nais.yaml,.nais/alert.yaml