Skip to content

Commit

Permalink
Merge pull request #2 from code0-tech/1-deployment-pipeline
Browse files Browse the repository at this point in the history
Create deployment pipeline
  • Loading branch information
Taucher2003 authored May 3, 2024
2 parents fdbaed3 + 6b48e1f commit a7905d8
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 1 deletion.
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI

on:
push:
branches:
- main
pull_request:

permissions:
pull-requests: write

jobs:
pipeline:
runs-on: ubuntu-latest
steps:
- uses: Taucher2003/[email protected]
name: Run pipeline
id: pipeline
with:
GL_SERVER_URL: https://gitlab.com
GL_PROJECT_ID: '57513325'
GL_RUNNER_TOKEN: ${{ secrets.GL_RUNNER_TOKEN }}
GL_API_TOKEN: ${{ secrets.GL_API_TOKEN }}
SHOW_JOB_LOGS: all
OVERRIDE_GITHUB_SHA: ${{ github.event_name == 'push' && github.sha || github.event.pull_request.head.sha }}
OVERRIDE_GITHUB_REF_NAME: ${{ github.event_name == 'push' && github.ref_name || github.event.pull_request.head.ref }}
env:
GLPA_C0_GH_REF: ${{ github.ref }}

- name: Find existing comment
uses: peter-evans/find-comment@v3
id: find-comment
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: <!-- glpa_comment:pipeline -->

- name: Create or update comment
uses: peter-evans/create-or-update-comment@v4
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
<!-- glpa_comment:pipeline -->
${{ steps.pipeline.outputs.SUMMARY_TEXT }}
edit-mode: replace
40 changes: 40 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.build-base:
image: node:20.9.0
script:
- npm ci
- npm run build

build:
extends:
- .build-base
stage: build
variables:
C0_BASE_PATH: /-/development/landing-page/-/jobs/$CI_JOB_ID/artifacts/out
after_script:
- |
echo -e "\e[0Ksection_start:`date +%s`:glpa_summary\r\e[0KHeader of the summary"
echo "Preview available at https://code0-tech.gitlab.io/-/development/landing-page/-/jobs/$CI_JOB_ID/artifacts/out/index.html"
echo -e "\e[0Ksection_end:`date +%s`:glpa_summary\r\e[0K"
environment:
name: preview/$CI_COMMIT_REF_SLUG
url: https://code0-tech.gitlab.io/-/development/landing-page/-/jobs/$CI_JOB_ID/artifacts/out/index.html
auto_stop_in: 7 days
artifacts:
paths:
- out
expire_in: 7 days
rules:
- if: $C0_GH_REF != "refs/heads/main"

pages:
extends:
- .build-base
stage: deploy
after_script:
- rm -rf public
- mv out public
artifacts:
paths:
- public
rules:
- if: $C0_GH_REF == "refs/heads/main"
12 changes: 11 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};
const nextConfig = {
output: 'export',
images: {
loader: 'custom',
loaderFile: './src/utils/image-loader.js',
},
};

if (process.env.C0_BASE_PATH) {
nextConfig.basePath = process.env.C0_BASE_PATH;
}

export default nextConfig;
3 changes: 3 additions & 0 deletions src/utils/image-loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function imageLoader({ src }) {
return `${process.env.C0_BASE_PATH ?? ''}${src}`;
}

0 comments on commit a7905d8

Please sign in to comment.