-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
942cc4f
commit 48e279d
Showing
24 changed files
with
226 additions
and
56 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
name: Build and deploy | ||
|
||
on: [ push ] | ||
|
||
env: | ||
IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }} | ||
LATEST_IMAGE: ghcr.io/${{ github.repository }}:latest | ||
|
||
jobs: | ||
install: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Cache node_modules | ||
uses: actions/cache@v4 | ||
id: node_modules | ||
with: | ||
path: ./node_modules | ||
key: modules-${{ hashFiles('package-lock.json') }} | ||
|
||
- uses: actions/setup-node@v4 | ||
if: steps.node_modules.outputs.cache-hit != 'true' | ||
with: | ||
node-version: "20.x" | ||
cache: "npm" | ||
|
||
- run: npm ci --ignore-scripts | ||
if: steps.node_modules.outputs.cache-hit != 'true' | ||
|
||
test: | ||
needs: [ install ] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.x" | ||
|
||
- name: Cache node_modules | ||
uses: actions/cache@v4 | ||
with: | ||
path: ./node_modules | ||
key: modules-${{ hashFiles('package-lock.json') }} | ||
|
||
- run: npm run test | ||
|
||
playwright: | ||
needs: [ install ] | ||
timeout-minutes: 2 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Cache node_modules | ||
uses: actions/cache@v4 | ||
id: node_modules | ||
with: | ||
path: ./node_modules | ||
key: modules-${{ hashFiles('package-lock.json') }} | ||
|
||
- uses: actions/setup-node@v4 | ||
if: steps.node_modules.outputs.cache-hit != 'true' | ||
with: | ||
node-version: "20.x" | ||
cache: "npm" | ||
registry-url: "https://npm.pkg.github.com" | ||
|
||
- name: "Install dependencies" | ||
run: npm ci --ignore-scripts | ||
if: steps.node_modules.outputs.cache-hit != 'true' | ||
|
||
- name: Store Playwright's Version | ||
run: | | ||
PLAYWRIGHT_VERSION=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//') | ||
echo "Playwright's Version: $PLAYWRIGHT_VERSION" | ||
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV | ||
- name: Cache Chromium browser for Playwright's Version | ||
id: cache-chromium-browser | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/ms-playwright | ||
key: chromium-with-playwright-version-${{ env.PLAYWRIGHT_VERSION }} | ||
|
||
- name: Install Chromium browser | ||
if: steps.cache-chromium-browser.outputs.cache-hit != 'true' | ||
run: npx playwright install chromium --with-deps | ||
|
||
- name: Run Playwright Tests | ||
run: npm run playwright:verbose | ||
|
||
- name: Store Artifacts from Failed Tests | ||
if: failure() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: test-results | ||
path: test-results/ | ||
retention-days: 7 | ||
|
||
build: | ||
needs: [ install ] | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.x" | ||
|
||
- name: Cache node_modules | ||
uses: actions/cache@v4 | ||
with: | ||
path: ./node_modules | ||
key: modules-${{ hashFiles('package-lock.json') }} | ||
|
||
- run: npm run build | ||
|
||
# Bygg docker image | ||
- uses: docker/setup-buildx-action@v3 | ||
- uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: true | ||
pull: true | ||
tags: ${{ env.IMAGE }},${{ env.LATEST_IMAGE }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- name: Cache static files | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
./build | ||
key: ${{ github.sha }} | ||
|
||
|
||
|
||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM node:20-alpine | ||
|
||
WORKDIR /app | ||
COPY build/ build/ | ||
COPY server/ server/ | ||
COPY public/ public/ | ||
COPY node_modules/ node_modules/ | ||
COPY package.json ./ | ||
COPY environment.js ./ | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["npm", "run", "start"] |
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
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.