Merge pull request #2097 from navikt/dev #2775
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, push, and deploy | |
on: [push] | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
CI: true | |
TZ: Europe/Oslo | |
Q1_TEST_BRANCH: refs/heads/branch_name | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
id-token: write | |
outputs: | |
image: ${{ steps.docker-build-push.outputs.image }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '16.13.1' | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm ci | |
- name: Test | |
run: npm run test | |
- name: Build | |
run: npm run build | |
- name: Upload sourcemaps | |
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/master' || github.ref == env.Q1_TEST_BRANCH | |
run: npm run upload-sourcemaps | |
- name: Publish Docker image | |
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/master' || github.ref == env.Q1_TEST_BRANCH | |
uses: nais/docker-build-push@v0 | |
id: docker-build-push | |
with: | |
team: personoversikt | |
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} | |
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} | |
- name: Deploy to Q1 (Test branch) | |
uses: nais/deploy/actions/deploy@v2 | |
if: github.ref == env.Q1_TEST_BRANCH | |
env: | |
PRINT_PAYLOAD: true | |
CLUSTER: dev-fss | |
RESOURCE: .nais/qa-template.yaml | |
VAR: q_env=q1,version=${{ github.sha }},image=${{ steps.docker-build-push.outputs.image }} | |
deploy-qa: | |
name: Deploy to preprod | |
needs: build | |
if: github.ref == 'refs/heads/dev' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
strategy: | |
matrix: | |
q_env: [q0, q1] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: nais/deploy/actions/deploy@v2 | |
env: | |
PRINT_PAYLOAD: true | |
CLUSTER: dev-fss | |
RESOURCE: .nais/qa-template.yaml | |
VAR: q_env=${{ matrix.q_env }},version=${{ github.sha }},image=${{ needs.build.outputs.image }} | |
deploy-prod: | |
name: Deploy to prod | |
needs: build | |
if: github.ref == 'refs/heads/master' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: nais/deploy/actions/deploy@v2 | |
env: | |
PRINT_PAYLOAD: true | |
CLUSTER: prod-fss | |
RESOURCE: .nais/prod.yaml | |
VAR: version=${{ github.sha }},image=${{ needs.build.outputs.image }} |