Skip to content

Commit 85baef4

Browse files
authored
feat : demo SPA added (#1)
1 parent 3a4ca2b commit 85baef4

23 files changed

+3918
-278
lines changed

.DS_Store

6 KB
Binary file not shown.

.github/workflows/ci.yaml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Workflow Demo SPA
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
tags:
8+
- '*'
9+
paths:
10+
- '*'
11+
workflow_dispatch:
12+
inputs:
13+
version:
14+
description: Bump Version
15+
default: v1.0.0
16+
required: true
17+
jobs:
18+
push_to_registry:
19+
name: Push Docker image to Registries
20+
env:
21+
IMAGE_NAME: "workflow"
22+
REGISTRY_NAMESPACE: ${{ secrets.REGISTRY_NAMESPACE }}
23+
USERGROUP: ${{ secrets.USER_GROUP }}
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Inject slug/short variables
27+
uses: rlespinasse/[email protected]
28+
29+
- name: Check out the repo
30+
uses: actions/checkout@v2
31+
32+
- name: Login to Quay.io
33+
uses: docker/login-action@v1
34+
with:
35+
registry: quay.io
36+
username: ${{ secrets.CI_QUAY_USERNAME }}
37+
password: ${{ secrets.CI_QUAY_TOKEN }}
38+
39+
- name: Build and push into repository
40+
id: docker_build
41+
uses: docker/build-push-action@v2
42+
with:
43+
context: .
44+
file: ./Dockerfile
45+
push: ${{ github.event_name != 'pull_request' }}
46+
build-args: USERGROUP=${{secrets.USER_GROUP}}
47+
tags: |
48+
quay.io/${{ env.REGISTRY_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{env.GITHUB_REF_SLUG}}
49+
- name: Image digest
50+
run: echo ${{ steps.docker_build.outputs.digest }}

.github/workflows/lighthouse.yaml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Lighthouse Audit
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
tags:
8+
- '*'
9+
paths:
10+
- '*'
11+
workflow_dispatch:
12+
inputs:
13+
version:
14+
description: Bump Version
15+
default: v1.0.0
16+
required: true
17+
18+
jobs:
19+
lighthouse:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout Repository
23+
uses: actions/checkout@v2
24+
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v2
27+
with:
28+
node-version: '20'
29+
30+
- name: Install Dependencies
31+
run: npm install -g lighthouse
32+
33+
- name: Run Lighthouse
34+
run: |
35+
lighthouse --no-enable-error-reporting --chrome-flags="--headless --disable-gpu" https://www.npmjs.com/package/@spotify/lighthouse-audit-service --output json html --output-path=./.lighthouseci/one-platform-test-env
36+
37+
38+
- name: Commit Lighthouse Reports
39+
uses: actions/github-script@v7
40+
with:
41+
github-token: ${{ secrets.GIT_TOKEN }}
42+
script: |
43+
const fs = require('fs');
44+
const path = require('path');
45+
46+
// Import GitHub context
47+
const github = require('@actions/github');
48+
49+
// Read the contents of the reports directory
50+
const reportsPath = '.lighthouseci';
51+
const reports = fs.readdirSync(reportsPath);
52+
53+
// Commit the reports to the repository
54+
const { data } = await github.rest.repos.createOrUpdateFile({
55+
owner: github.context.repo.owner,
56+
repo: github.context.repo.repo,
57+
path: 'lighthouse-reports',
58+
message: 'Add Lighthouse Reports',
59+
content: Buffer.from(reports.join('\n')).toString('base64'),
60+
});
61+
62+
console.log(`Lighthouse reports committed. SHA: ${data.content.sha}`);

Dockerfile

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Use the official Node.js image as the base
2+
FROM node:18-alpine3.16
3+
4+
ARG TESTWORKFLOW
5+
ARG DEMOWORKFLOW
6+
ARG USERGROUP
7+
8+
RUN addgroup allusers && adduser -S -G allusers $USERGROUP
9+
RUN mkdir /.npm
10+
RUN mkdir /.npm/_cacache
11+
12+
RUN echo "Build argument value of TESTWORKFLOW : ${TESTWORKFLOW}"
13+
RUN echo "Build argument value of DEMOWORKFLOW : ${DEMOWORKFLOW}"
14+
# Set the working directory
15+
WORKDIR /app
16+
17+
# Copy package.json and package-lock.json
18+
COPY package.json ./
19+
COPY package-lock.json ./
20+
21+
# Install dependencies
22+
RUN npm install --production
23+
24+
# Copy the rest of the application
25+
COPY . .
26+
27+
# Set environment variables
28+
ENV NODE_ENV=production
29+
30+
# Build the application
31+
RUN npm run build
32+
33+
# Remove development dependencies
34+
RUN npm prune --production
35+
36+
RUN chown -R $USERGROUP:allusers .
37+
RUN chown -R $USERGROUP:allusers ~/.npm
38+
RUN chown -R $USERGROUP:allusers /.npm
39+
RUN chmod -R 777 .
40+
EXPOSE 3000
41+
USER $USERGROUP
42+
43+
# Start the application
44+
CMD ["npm", "start"]

0 commit comments

Comments
 (0)