Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Actions] ⚡ Optimize workflows #3480

Merged
merged 36 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
53c0aa5
:truck: Moved auth-token, fetch less history
KenAJoh Dec 20, 2024
2c83169
:recycle: Use composite actions for workflow
KenAJoh Dec 20, 2024
99e90aa
:bug: Checkout before running composite workflow
KenAJoh Dec 20, 2024
598ddce
:truck: Move composite actions to separate dir
KenAJoh Dec 20, 2024
f979ea1
:recycle: Pass token to composite action
KenAJoh Dec 20, 2024
130088e
:memo: Better test names
KenAJoh Dec 20, 2024
4f913f3
:zap: Optimize chromatic workflow
KenAJoh Dec 20, 2024
5c44940
:coffin: Removed old and broken redeploy action
KenAJoh Dec 21, 2024
2fb3499
:zap: Optimized website-build
KenAJoh Dec 21, 2024
8f0df3d
:recycle: Use composite actions for prod and dev build
KenAJoh Dec 21, 2024
ff52863
:zap: Reduced e2e tests by 40%
KenAJoh Dec 21, 2024
612d468
:zap: Improved sandbox testing
KenAJoh Dec 22, 2024
de10a97
:zap: Update search-tests
KenAJoh Dec 22, 2024
6da41b5
:bug: Disable invalid example-demos
KenAJoh Dec 22, 2024
bb16f9f
:bug: Wait for search completion
KenAJoh Dec 22, 2024
ce27eea
:memo: removed old env input
KenAJoh Dec 22, 2024
42dce41
:bug: Moved vars out to input
KenAJoh Dec 22, 2024
d58a90b
:bug: Don't ignore inputs for if-tests
KenAJoh Dec 22, 2024
bc434ed
:bug: Check input for truuthynes
KenAJoh Dec 22, 2024
eb0cf4b
test: Run sharded playwright
KenAJoh Dec 22, 2024
295fa6d
:bug: Removed sharded workflow
KenAJoh Dec 22, 2024
6558a00
:zap: Update re-use of actions
KenAJoh Dec 23, 2024
a6014e0
:bug: Keep full git-history for chroamtic
KenAJoh Dec 23, 2024
f94ce74
Merge branch 'main' into optimize-workflows
KenAJoh Dec 28, 2024
f89024f
Update .github/workflows/chromatic.yml
KenAJoh Jan 9, 2025
3d356ac
Update .github/workflows/referansesider-spa-deploy.yml
KenAJoh Jan 9, 2025
7bc457c
Update .github/workflows/ci.yml
KenAJoh Jan 9, 2025
6037981
Update .github/workflows/ci.yml
KenAJoh Jan 9, 2025
8d352ee
Update .github/workflows/ci.yml
KenAJoh Jan 9, 2025
ca68dc2
Update .github/workflows/ci.yml
KenAJoh Jan 9, 2025
1139121
Update .github/workflows/ci.yml
KenAJoh Jan 9, 2025
db81c16
Update .github/workflows/ci.yml
KenAJoh Jan 9, 2025
7c5c238
:memo: Typo
KenAJoh Jan 9, 2025
f29625b
:memo: Typoo
KenAJoh Jan 9, 2025
77c7fab
:zap: Use built-in report for playwright
KenAJoh Jan 9, 2025
fe955a3
:bug: Use html-reporter, not list
KenAJoh Jan 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ module.exports = {
},
},
{
files: ["**/examples/__parts*/*.tsx"],
files: [
"**/examples/__parts*/*.tsx",
"**/pages/templates/**/*.tsx",
"**/pages/eksempler/**/*.tsx",
],
plugins: ["aksel-local"],
rules: {
"aksel-local/import-check": ["error"], // Only allow imports from @navikt and react
Expand Down
56 changes: 56 additions & 0 deletions .github/actions/build-website/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "Build website"
description: "Builds Nextjs-website and published CDN-asssets to GCP if needed"
inputs:
use_cdn_assets:
description: "Use CDN assets, and upload build to GCP"
required: true
npm_auth_token:
description: "NPM Auth Token"
required: true
nais_id_provider:
description: "NAIS_WORKLOAD_IDENTITY_PROVIDER token"
required: true
nais_project_id:
description: "NAIS_MANAGEMENT_PROJECT_ID token"
required: true
sanity_read_token:
description: "Sanity read-only token allowing published and un-published documents"
required: true
sanity_read_no_drafts_token:
description: "Sanity read-only token allowing only published documents"
required: true

runs:
using: "composite"
steps:
- name: Setup project
uses: ./.github/actions/setup
with:
npm_auth_token: ${{ inputs.npm_auth_token }}

- name: Run website tests
run: yarn workspace website test
shell: bash

- name: Make Next.js app use CDN assets
if: ${{ inputs.use_cdn_assets == 'true' }}
run: |
echo "USE_CDN_ASSETS=true" >> aksel.nav.no/website/.env
shell: bash

- name: Build Next.js website
run: yarn build:next
env:
SANITY_READ: ${{ inputs.sanity_read_token }}
SANITY_READ_NO_DRAFTS: ${{ inputs.sanity_read_no_drafts_token }}
shell: bash

- name: Upload static files to Nav CDN
if: ${{ inputs.use_cdn_assets == 'true' }}
uses: nais/deploy/actions/cdn-upload/v2@master
with:
team: designsystem
source: ./aksel.nav.no/website/.next/static
destination: "/website/_next"
project_id: ${{ inputs.nais_project_id }}
identity_provider: ${{ inputs.nais_id_provider }}
26 changes: 26 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Setup Project"
description: "Checks out repo, sets up Node, installs dependencies and runs boot command."
inputs:
npm_auth_token:
description: "NPM Auth Token"
required: true

runs:
using: "composite"
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: yarn
cache-dependency-path: "**/yarn.lock"

- name: Install dependencies
run: yarn
shell: bash
env:
NPM_AUTH_TOKEN: ${{ inputs.npm_auth_token }}

- name: Boot (build packages)
run: yarn boot
shell: bash
44 changes: 11 additions & 33 deletions .github/workflows/aksel-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,20 @@ jobs:
contents: "read"
id-token: "write"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Checkout code
uses: actions/checkout@v4
with:
node-version: lts/*
cache: yarn
- name: set-env for yarn install to @navikt scope
shell: bash
run: echo "NPM_AUTH_TOKEN=${{ secrets.READER_TOKEN }}" >> $GITHUB_ENV
fetch-depth: 1

- name: add tokens to .env
run: |
echo "USE_CDN_ASSETS=true" >> aksel.nav.no/website/.env

- name: Hide page from search engines
run: |
echo "User-agent: *\nDisallow: /" > aksel.nav.no/website/public/robots.txt

- name: Install dependencies
run: yarn

- name: Build application
env:
SANITY_READ: ${{ secrets.SANITY_READ }}
SANITY_READ_NO_DRAFTS: ${{ secrets.SANITY_READ_NO_DRAFTS }}
run: |
yarn boot
yarn workspace aksel.nav.no build:next

- name: Upload static files to Nav CDN
uses: nais/deploy/actions/cdn-upload/v2@master
- name: Setup and build Next.js application
uses: ./.github/actions/build-website
with:
team: designsystem
source: ./aksel.nav.no/website/.next/static
destination: "/website/_next"
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
use_cdn_assets: true
npm_auth_token: ${{ secrets.READER_TOKEN }}
nais_id_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
nais_project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
sanity_read_token: ${{ secrets.SANITY_READ }}
sanity_read_no_drafts_token: ${{ secrets.SANITY_READ_NO_DRAFTS }}

- name: Get complete tag
run: echo "TAG=DEV-$( date +%s )" >> $GITHUB_ENV
Expand Down
63 changes: 16 additions & 47 deletions .github/workflows/aksel-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,13 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
- name: Setup project
uses: ./.github/actions/setup
with:
node-version: lts/*
cache: yarn
- name: set-env for yarn install to @navikt scope
shell: bash
run: echo "NPM_AUTH_TOKEN=${{ secrets.READER_TOKEN }}" >> $GITHUB_ENV
npm_auth_token: ${{ secrets.READER_TOKEN }}

- name: Install dependencies
run: yarn

- name: Run docgen
run: |
yarn boot
yarn docgen
- name: Run ts-docgen
run: yarn docgen

- name: Update sanity sync
env:
Expand All @@ -45,43 +37,20 @@ jobs:
contents: "read"
id-token: "write"
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
- name: Checkout code
uses: actions/checkout@v4
with:
node-version: lts/*
cache: yarn
- name: set-env for yarn install to @navikt scope
shell: bash
run: echo "NPM_AUTH_TOKEN=${{ secrets.READER_TOKEN }}" >> $GITHUB_ENV

- name: add tokens to .env
run: |
echo "USE_CDN_ASSETS=true" >> aksel.nav.no/website/.env

- name: Install dependencies
run: yarn

- name: Build packages
run: yarn boot
fetch-depth: 1

- name: Tests
run: yarn workspace website test

- name: Build application
env:
SANITY_READ: ${{ secrets.SANITY_READ }}
SANITY_READ_NO_DRAFTS: ${{ secrets.SANITY_READ_NO_DRAFTS }}
run: yarn workspace aksel.nav.no build:next

- name: Upload static files to Nav CDN
uses: nais/deploy/actions/cdn-upload/v2@master
- name: Setup and build Next.js application
uses: ./.github/actions/build-website
with:
team: designsystem
source: ./aksel.nav.no/website/.next/static
destination: "/website/_next"
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
use_cdn_assets: true
npm_auth_token: ${{ secrets.READER_TOKEN }}
nais_id_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
nais_project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
sanity_read_token: ${{ secrets.SANITY_READ }}
sanity_read_no_drafts_token: ${{ secrets.SANITY_READ_NO_DRAFTS }}

- name: Get complete tag
run: echo "TAG=PROD-$( date +%s )" >> $GITHUB_ENV
Expand Down
42 changes: 0 additions & 42 deletions .github/workflows/aksel-redeploy.yml

This file was deleted.

9 changes: 5 additions & 4 deletions .github/workflows/backup-sanity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@ jobs:
with:
node-version: lts/*
cache: yarn
- name: set-env for yarn install to @navikt scope
shell: bash
run: echo "NPM_AUTH_TOKEN=${{ secrets.READER_TOKEN }}" >> $GITHUB_ENV
cache-dependency-path: "**/yarn.lock"

- name: Install dependencies
run: cd aksel.nav.no/website && yarn
env:
NPM_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}

- name: Export dataset
run: cd aksel.nav.no/website && yarn backup
env:
SANITY_READ: ${{ secrets.SANITY_READ }}
run: cd aksel.nav.no/website && yarn backup

- name: Upload GCP bucket
uses: "google-github-actions/auth@v2"
with:
Expand Down
20 changes: 5 additions & 15 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,21 @@ concurrency:

jobs:
chromatic:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'ignore-chromatic') }}
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v4
- name: Setup project
KenAJoh marked this conversation as resolved.
Show resolved Hide resolved
uses: ./.github/actions/setup
with:
node-version: lts/*
cache: yarn

- name: set-env for yarn install to @navikt scope
shell: bash
run: echo "NPM_AUTH_TOKEN=${{ secrets.READER_TOKEN }}" >> $GITHUB_ENV

- name: Install dependencies
run: yarn

- name: Build packages
run: yarn boot
npm_auth_token: ${{ secrets.READER_TOKEN }}

- name: Chromatic
uses: chromaui/action@latest
Expand Down
Loading
Loading