|
| 1 | +name: Frontend |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - ".github/workflows/etterlevelse-frontend.yml" |
| 7 | + - "apps/frontend/**" |
| 8 | + |
| 9 | +env: |
| 10 | + IMAGE: docker.pkg.github.com/${{ github.repository }}/etterlevelsefront${{ github.ref == 'refs/heads/prod' }}:${{ github.sha }} |
| 11 | + |
| 12 | +defaults: |
| 13 | + run: |
| 14 | + working-directory: apps/frontend |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + name: Frontend - build and push docker |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v1 |
| 23 | + - name: Set up node |
| 24 | + uses: actions/setup-node@v1 |
| 25 | + with: |
| 26 | + node-version: "13.x" |
| 27 | + |
| 28 | + - name: npm install |
| 29 | + run: npm i |
| 30 | + - name: use prod config |
| 31 | + if: github.ref == 'refs/heads/prod' |
| 32 | + run: cp .env.prod .env |
| 33 | + - name: add version |
| 34 | + env: |
| 35 | + GITHUB_SHA: ${{ github.sha }} |
| 36 | + run: echo "REACT_APP_GIT_VERSION=${GITHUB_SHA}" >> .env |
| 37 | + |
| 38 | + - name: Build |
| 39 | + run: CI=false npm run build |
| 40 | + - name: Docker |
| 41 | + env: |
| 42 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + run: | |
| 44 | + docker build --tag ${IMAGE} . |
| 45 | + docker login docker.pkg.github.com -u ${GITHUB_REPOSITORY} -p ${GITHUB_TOKEN} |
| 46 | + docker push ${IMAGE} |
| 47 | +
|
| 48 | + deploy-preprod: |
| 49 | + name: Frontend - deploy Dev GCP |
| 50 | + needs: build |
| 51 | + if: github.ref == 'refs/heads/master' |
| 52 | + runs-on: ubuntu-latest |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v1 |
| 55 | + - uses: nais/deploy/actions/deploy@v1 |
| 56 | + env: |
| 57 | + APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} |
| 58 | + CLUSTER: dev-gcp |
| 59 | + RESOURCE: apps/frontend/nais/frontend-gcp.yaml |
| 60 | + VARS: apps/frontend/nais/frontend-dev-gcp-vars.yaml |
| 61 | + ENVIRONMENT: dev-gcp:teamdatajegerne:etterlevelse-frontend |
| 62 | + |
| 63 | + deploy-prod: |
| 64 | + name: Frontend - deploy Prod GCP |
| 65 | + needs: build |
| 66 | + if: github.ref == 'refs/heads/prod' |
| 67 | + runs-on: ubuntu-latest |
| 68 | + steps: |
| 69 | + - uses: actions/checkout@v1 |
| 70 | + - uses: nais/deploy/actions/deploy@v1 |
| 71 | + env: |
| 72 | + APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} |
| 73 | + CLUSTER: prod-gcp |
| 74 | + RESOURCE: apps/frontend/nais/frontend-gcp.yaml |
| 75 | + VARS: apps/frontend/nais/frontend-prod-gcp-vars.yaml |
| 76 | + ENVIRONMENT: prod-gcp:teamdatajegerne:etterlevelse-frontend |
0 commit comments