Skip to content

Commit

Permalink
GitHub action parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
cskrov committed Aug 29, 2024
1 parent 3585abc commit 3de37a9
Showing 1 changed file with 76 additions and 33 deletions.
109 changes: 76 additions & 33 deletions .github/workflows/deploy-to-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,47 +26,48 @@ on:
run-name: Dev deploy of ${{ github.ref_name }}

jobs:
build:
name: Build
build-frontend:
name: Build frontend
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
permissions:
contents: read
id-token: write
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
version: ${{ steps.version.outputs.version }}
artifact-id: ${{ steps.upload.outputs.artifact-id }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v1
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
registry-url: https://npm.pkg.github.com/
registry-url: "https://npm.pkg.github.com/"
scope: "@navikt"

- name: Install frontend dependencies
shell: bash
run: |
cd frontend
bun install --frozen-lockfile
env:
BUN_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
BUN_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
run: bun install --frozen-lockfile

- name: Test frontend
shell: bash
run: |
cd frontend
bun test
run: bun test

- name: Build frontend
shell: bash
env:
VERSION: ${{ github.sha }}
run: |
cd frontend
bun run build
run: bun run build

- name: Store index.html artifact
id: upload
uses: actions/upload-artifact@v4
with:
name: index.html
path: ./frontend/dist/index.html

- name: Upload static files to CDN
uses: nais/deploy/actions/cdn-upload/v2@master
Expand All @@ -76,31 +77,73 @@ jobs:
destination: klang
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}


build-server:
name: Build server
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./server
permissions:
contents: read
id-token: write
outputs:
artifact-id: ${{ steps.upload.outputs.artifact-id }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
registry-url: "https://npm.pkg.github.com/"
scope: "@navikt"

- name: Install server dependencies
shell: bash
run: |
cd server
bun install --frozen-lockfile
env:
BUN_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
run: bun install --frozen-lockfile

- name: Test server
shell: bash
run: |
cd server
bun test
run: bun test

- name: Build server
shell: bash
run: |
cd server
bun run build
run: bun run build

- name: Store server files artifact
id: upload
uses: actions/upload-artifact@v4
with:
name: server
path: ./server/dist

build-image:
name: Build Docker image
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
needs: [build-frontend, build-server]
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
steps:
- name: Generate version number
id: version
run: echo "version=$(TZ="Europe/Oslo" git show -s --format=%cd --date='format-local:%Y-%m-%dT%H:%M:%S')" >> "$GITHUB_OUTPUT"

- name: Fetch index.html artifact
uses: actions/download-artifact@v4
with:
name: ${{ needs.build-frontend.outputs.artifact-id }}
path: ./frontend/dist/index.html

- name: Fetch server files artifact
uses: actions/download-artifact@v4
with:
name: ${{ needs.build-server.outputs.artifact-id }}
path: ./server/dist

- name: Build & push Docker image
uses: nais/docker-build-push@v0
id: docker-build-push
Expand All @@ -124,7 +167,7 @@ jobs:
permissions:
contents: read
id-token: write
needs: build
needs: build-image
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -135,7 +178,7 @@ jobs:
CLUSTER: dev-gcp
VARS: nais/dev.yaml
RESOURCE: nais/nais.yaml
VAR: image=${{ needs.build.outputs.image }}
VAR: image=${{ needs.build-image.outputs.image }}

e2e_test:
name: E2E
Expand Down

0 comments on commit 3de37a9

Please sign in to comment.