Bygg og test chore: cleans up older non-reprodusable issues #3552
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: Pull request | |
on: | |
pull_request: | |
branches: ["main"] | |
merge_group: | |
types: [checks_requested] | |
run-name: Bygg og test ${{ github.event_name == 'merge_group' && github.event.merge_group.head_commit.message || github.event.pull_request.title }} | |
env: | |
PREVIEW_PATH: preview/${{ github.event.pull_request.head.ref }} | |
PREFIX_PATHS: true | |
jobs: | |
build: | |
name: Sjekk for endringer og bygg pakker | |
if: ${{ !contains(github.event.sender.login, 'fremtind-bot') }} | |
outputs: | |
preview: ${{ steps.changes.outputs.preview }} | |
testlint: ${{ steps.changes.outputs.testlint }} | |
runs-on: ubuntu-latest | |
permissions: | |
actions: write | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Check for changes that require extra verification | |
if: ${{ github.event_name != 'merge_group' }} | |
uses: ./actions/paths-filter | |
id: changes | |
with: | |
filters: | | |
testlint: | |
- "**/*.js" | |
- "**/*.scss" | |
- "**/*.ts" | |
- "**/*.tsx" | |
- "**/vite.test.config.mjs" | |
- "pnpm-lock.yaml" | |
preview: | |
- "packages/**/*.scss" | |
- "packages/core/**/!(*.d|*.test).ts" | |
- "packages/core/**/!(*.test).tsx" | |
- "packages/*-react/**/!(*.d|*.test).ts" | |
- "packages/*-react/**/!(*.test).tsx" | |
- "pnpm-lock.yaml" | |
- "packages/**/*.mdx" | |
- "portal/src/texts/**" | |
- name: Setup pnpm | |
if: steps.changes.outputs.has_matches == 'true' || github.event_name == 'merge_group' | |
uses: pnpm/action-setup@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
if: steps.changes.outputs.has_matches == 'true' || github.event_name == 'merge_group' | |
with: | |
node-version: 18 | |
cache: "pnpm" | |
- name: Restore Monorepo Runner Cache | |
if: github.event_name == 'merge_group' | |
uses: actions/cache/restore@v3 | |
with: | |
path: .nx | |
key: nx-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }} | |
restore-keys: | | |
nx-${{ hashFiles('pnpm-lock.yaml') }}- | |
- name: Cache Monorepo Runner | |
if: github.event_name == 'pull_request' && steps.changes.outputs.has_matches == 'true' | |
uses: actions/cache@v3 | |
with: | |
path: .nx | |
key: nx-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }} | |
restore-keys: | | |
nx-${{ hashFiles('pnpm-lock.yaml') }}- | |
- name: Install dependencies | |
if: steps.changes.outputs.has_matches == 'true' || github.event_name == 'merge_group' | |
run: pnpm install | |
- name: Build packages | |
if: steps.changes.outputs.has_matches == 'true' || github.event_name == 'merge_group' | |
run: pnpm build | |
preview: | |
name: Publiser forhåndsvisning | |
needs: [build] | |
if: github.event_name != 'merge_group' && needs.build.outputs.preview == 'true' | |
runs-on: ubuntu-latest | |
permissions: | |
actions: write | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: "pnpm" | |
- name: Restore Monorepo Runner Cache | |
uses: actions/cache/restore@v3 | |
with: | |
path: .nx | |
key: nx-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }} | |
restore-keys: | | |
nx-${{ hashFiles('pnpm-lock.yaml') }}- | |
# Steget må være med, men vil være cachet | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build packages | |
run: pnpm build | |
- name: Add a comment with a link to the preview | |
uses: marocchino/sticky-pull-request-comment@da224cb0e3c8b27cae68d40c93649421b5b93e45 | |
with: | |
header: preview | |
GITHUB_TOKEN: ${{ secrets.FREMTIND_BOT_ACCESS_TOKEN }} | |
message: | | |
<span aria-hidden="true">🔄</span> **Gjør klar en forhåndsvisning…** | |
<span aria-hidden="true">🔍</span> Commit: ${{ github.sha }} | |
- name: Build site | |
env: | |
GATSBY_MIXPANEL_PROJECT_ID: ${{ secrets.MIXPANEL_PROJECT_ID_TEST }} | |
run: pnpm build:docs | |
- name: Deploy preview | |
env: | |
GH_TOKEN: ${{ secrets.BOT_PUBLISH_TOKEN }} | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "fremtind-bot" | |
git remote set-url origin https://x-access-token:${GH_TOKEN}@github.com/fremtind/jokul.git | |
pnpm gh-pages --add --dist portal/public --dest ${{ env.PREVIEW_PATH }} --message "docs: preview #${{ github.event.number }}" | |
- name: Add a comment with a link to the preview | |
uses: marocchino/sticky-pull-request-comment@da224cb0e3c8b27cae68d40c93649421b5b93e45 | |
with: | |
header: preview | |
GITHUB_TOKEN: ${{ secrets.FREMTIND_BOT_ACCESS_TOKEN }} | |
message: | | |
<span aria-hidden="true">✅</span> Forhåndsvisning: https://jokul.fremtind.no/${{ env.PREVIEW_PATH }}/ | |
<span aria-hidden="true">🔍</span> Commit: ${{ github.sha }} | |
Forhåndsvisningen blir tilgjengelig innen et par minutter. Den fjernes automatisk når pull requesten lukkes. | |
testlint: | |
name: Kjør tester og linting | |
needs: [build] | |
if: github.event_name == 'merge_group' || (needs.build.outputs.testlint == 'true' && !contains(github.event.sender.login, 'fremtind-bot')) | |
runs-on: ubuntu-latest | |
permissions: | |
actions: read | |
contents: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: "pnpm" | |
- name: Restore Monorepo Runner Cache | |
uses: actions/cache/restore@v3 | |
with: | |
path: .nx | |
key: nx-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }} | |
restore-keys: | | |
nx-${{ hashFiles('pnpm-lock.yaml') }}- | |
# Steget må være med, men vil være cachet | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build packages | |
run: pnpm build | |
- name: Lint and test | |
run: pnpm ci:test |