|
15 | 15 | BASE_IMAGE: docker.pkg.github.com/${{ github.repository }}/sykdom-i-familien
|
16 | 16 | GITHUB_USERNAME: x-access-token
|
17 | 17 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
| 18 | + DATASET: multisite |
| 19 | + IMAGE: docker.pkg.github.com/${{ github.repository }}/sykdom-i-familien-preview:${{ github.sha }} |
18 | 20 |
|
19 | 21 | jobs:
|
20 | 22 | test:
|
@@ -62,50 +64,50 @@ jobs:
|
62 | 64 | - id: debug
|
63 | 65 | run: echo "${BASE_IMAGE}:${TAG}"
|
64 | 66 |
|
65 |
| - build-code-and-push-docker-dev: |
66 |
| - name: staging-build-push-docker |
67 |
| - if: github.event.action == 'publish-dev-sbs' # Build and push docker if publish staging event from sanity studio |
68 |
| - needs: set-image |
69 |
| - runs-on: ubuntu-latest |
70 |
| - env: |
71 |
| - IMAGE: ${{ needs.set-image.outputs.image }} |
72 |
| - steps: |
73 |
| - - name: Checkout code |
74 |
| - uses: actions/checkout@v1 |
75 |
| - - name: Cache NPM dependencies |
76 |
| - uses: actions/cache@v1 |
77 |
| - with: |
78 |
| - path: node_modules |
79 |
| - key: ${{ runner.OS }}-npm-cache-${{ hashFiles('**/package-lock.json') }} |
80 |
| - restore-keys: | |
81 |
| - ${{ runner.OS }}-npm-cache- |
82 |
| - - name: Use Node.js ${{ matrix.node-version }} |
83 |
| - uses: actions/setup-node@v1 |
84 |
| - with: |
85 |
| - node-version: ${{ matrix.node-version }} |
86 |
| - |
87 |
| - - name: build code |
88 |
| - env: |
89 |
| - SANITY_TOKEN: ${{ secrets.SANITY_TOKEN }} |
90 |
| - DATASET: production |
91 |
| - ENV: dev |
92 |
| - OVERLAY_DRAFTS: true |
93 |
| - WATCH_MODE: true |
94 |
| - run: | |
95 |
| - echo "Exported DATASET=$DATASET" |
96 |
| - npm i |
97 |
| - npm run build |
98 |
| - - name: Build Docker image |
99 |
| - run: | |
100 |
| - docker build -t ${IMAGE} . -f Dockerfile-dev |
101 |
| - - name: Login to Github Package Registry |
102 |
| - env: |
103 |
| - DOCKER_USERNAME: x-access-token |
104 |
| - DOCKER_PASSWORD: ${{ env.GITHUB_TOKEN }} |
105 |
| - run: | |
106 |
| - echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin docker.pkg.github.com |
107 |
| - - name: Push Docker image |
108 |
| - run: 'docker push ${IMAGE}' |
| 67 | + build-code-and-push-docker-preview: |
| 68 | + name: Build code and push docker preview image |
| 69 | + if: startsWith(github.ref, 'refs/heads/preview-') || github.event.action == 'publish-dev-sbs' # Build and push docker if branch is either master or dev-* |
| 70 | + needs: test |
| 71 | + runs-on: ubuntu-latest |
| 72 | + steps: |
| 73 | + - name: Checkout code |
| 74 | + uses: actions/checkout@v1 |
| 75 | + - name: Cache NPM dependencies |
| 76 | + uses: actions/cache@v1 |
| 77 | + with: |
| 78 | + path: node_modules |
| 79 | + key: ${{ runner.OS }}-npm-cache-${{ hashFiles('**/package-lock.json') }} |
| 80 | + restore-keys: | |
| 81 | + ${{ runner.OS }}-npm-cache- |
| 82 | + - name: Use Node.js ${{ matrix.node-version }} |
| 83 | + uses: actions/setup-node@v1 |
| 84 | + with: |
| 85 | + node-version: ${{ matrix.node-version }} |
| 86 | + - name: Use Node.js ${{ matrix.node-version }} |
| 87 | + uses: actions/setup-node@v1 |
| 88 | + with: |
| 89 | + node-version: ${{ matrix.node-version }} |
| 90 | + - name: build code |
| 91 | + env: |
| 92 | + SANITY_TOKEN: ${{ secrets.SANITY_TOKEN }} |
| 93 | + DATASET: multisite |
| 94 | + ENV: dev |
| 95 | + OVERLAY_DRAFTS: true |
| 96 | + WATCH_MODE: false |
| 97 | + run: | |
| 98 | + echo "Exported DATASET=$DATASET" |
| 99 | + npm i |
| 100 | + npm run build-preview |
| 101 | + - name: Build Docker image |
| 102 | + run: | |
| 103 | + docker build -t ${IMAGE} . -f Dockerfile-dev |
| 104 | + - name: Login to Github Package Registry |
| 105 | + env: |
| 106 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 107 | + run: | |
| 108 | + docker login docker.pkg.github.com -u ${GITHUB_REPOSITORY} -p ${GITHUB_TOKEN} |
| 109 | + docker push ${IMAGE} |
| 110 | +
|
109 | 111 |
|
110 | 112 | build-code-and-push-docker-prod:
|
111 | 113 | name: prod-build-push-docker
|
@@ -155,20 +157,19 @@ jobs:
|
155 | 157 | - name: Push Docker image
|
156 | 158 | run: 'docker push ${IMAGE}'
|
157 | 159 |
|
158 |
| - deploy-dev-sbs: |
159 |
| - name: deploy-dev-sbs |
160 |
| - needs: [build-code-and-push-docker-dev, set-image] # Depends on build-code-and-push-docker job |
161 |
| - runs-on: ubuntu-latest |
162 |
| - steps: |
163 |
| - - name: Checkout code |
164 |
| - uses: actions/checkout@v1 |
165 |
| - - name: deploy to dev-sbs |
166 |
| - uses: nais/deploy/actions/deploy@v1 |
167 |
| - env: |
168 |
| - IMAGE: ${{ needs.set-image.outputs.image }} |
169 |
| - APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} |
170 |
| - CLUSTER: dev-sbs |
171 |
| - RESOURCE: nais/dev-sbs.yml |
| 160 | + deploy-dev-gcp: |
| 161 | + name: Deploy to dev-gcp |
| 162 | + if: github.event.action == 'publish-dev-sbs' || startsWith(github.ref, 'refs/heads/preview-') || startsWith(github.ref, 'refs/heads/master') # Build and push docker if branch is either master or dev-* |
| 163 | + needs: build-code-and-push-docker-preview |
| 164 | + runs-on: ubuntu-latest |
| 165 | + steps: |
| 166 | + - uses: actions/checkout@v1 |
| 167 | + - uses: nais/deploy/actions/deploy@v1 |
| 168 | + env: |
| 169 | + APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} |
| 170 | + CLUSTER: dev-gcp |
| 171 | + RESOURCE: nais/naiserator-dev.yml |
| 172 | + VARS: nais/dev-gcp.json |
172 | 173 |
|
173 | 174 | deploy-prod-sbs:
|
174 | 175 | name: deploy-prod-sbs
|
|
0 commit comments