Skip to content

Commit

Permalink
modify github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadim Ritter committed Sep 25, 2024
1 parent 012d857 commit fbfe81f
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 43 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/docker-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
tag_name: [test1, test2]
path_name: ["", "/sps-gui", "/proctoring-gui"],
tag_suffix: ["", "single-host", "single-host2"],

steps:
- name: Set env for dynamic tag
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
run: echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
run: echo "TAG_NAME=${GITHUB_REF#refs/*/}-${{ matrix.tag_suffix }}" >> $GITHUB_ENV

- name: Set env manual
if: github.event_name == 'workflow_dispatch'
run: echo "TAG_NAME=${{ matrix.tag_name }}" >> $GITHUB_ENV
run: echo "TAG_NAME=default_version-${{ matrix.tag_suffix }}" >> $GITHUB_ENV

- name: Checkout code
uses: actions/[email protected]
Expand All @@ -30,11 +32,13 @@ jobs:
uses: docker/[email protected]
with:
username: naritter
password: ${{ secrets.DOCKERHUB_PASSWORD }}
password: ${{ secrets.DOCKERHUB_PASSWORD}}

- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
push: true
tags: docker.io/naritter/seb-sps-gui:${{ env.TAG_NAME }}
build-args:
VITE_SUB_PATH: ${{ matrix.path_name }}
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ WORKDIR /app/client
COPY client/package*.json ./
RUN npm install
COPY client/ .

# Inject environment variables for Vue.js
ARG VUE_APP_MY_ENV_VAR
RUN echo "VITE_SUB_PATH=$VITE_SUB_PATH" > .env

RUN npm run build

# Stage 2: Build the Express server
Expand Down
2 changes: 1 addition & 1 deletion client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="UTF-8" />
<link rel="icon" href="/img/seb-logo-no-border.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="/env.js"></script>
<script src="<%= process.env.VITE_SUB_PATH %>/env.js"></script>
<title>SEB Screen Proctoring</title>
</head>

Expand Down
2 changes: 1 addition & 1 deletion client/src/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const routes: Array<RouteRecordRaw> = [
];

const router = createRouter({
history: createWebHistory(),
history: createWebHistory(process.env.VITE_SUB_PATH),
routes
});

Expand Down
82 changes: 45 additions & 37 deletions client/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,52 @@ import { gitTagPlugin } from "./src/plugins/vite-plugin-git-tag";


// Utilities
import { defineConfig } from "vite"
import { defineConfig, loadEnv } from "vite"
import { fileURLToPath, URL } from "node:url"


// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue({
template: { transformAssetUrls }
}),
// https://github.com/vuetifyjs/vuetify-loader/tree/next/packages/vite-plugin
vuetify({
autoImport: true,
}),
VueI18nPlugin({
include: fileURLToPath(new URL("./src/i18n/locales/**", import.meta.url)),
}),
// gitTagPlugin()
],
define: {
"process.env": {},
_global: ({})
},
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url))
},
extensions: [
".js",
".json",
".jsx",
".mjs",
".ts",
".tsx",
".vue",
],
},
server: {
port: 8081,
},
})
// export default defineConfig({
export default ({ mode }) => {
process.env = {...process.env, ...loadEnv(mode, process.cwd())};

return defineConfig({
plugins: [
vue({
template: { transformAssetUrls }
}),
// https://github.com/vuetifyjs/vuetify-loader/tree/next/packages/vite-plugin
vuetify({
autoImport: true,
}),
VueI18nPlugin({
include: fileURLToPath(new URL("./src/i18n/locales/**", import.meta.url)),
}),
// gitTagPlugin()
],
define: {
"process.env": {},
_global: ({})
},
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url))
},
extensions: [
".js",
".json",
".jsx",
".mjs",
".ts",
".tsx",
".vue",
],
},
server: {
port: 8081,
},

base: process.env.VITE_SUB_PATH

});
}

0 comments on commit fbfe81f

Please sign in to comment.