-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
2755e9a
commit 4800ecb
Showing
9 changed files
with
366 additions
and
1 deletion.
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,25 @@ | ||
name: 'build template' | ||
description: 'build template archive' | ||
# We declare that the action takes two arguments in input | ||
inputs: | ||
project: | ||
description: 'Project' | ||
required: true | ||
tag: | ||
description: 'Tag' | ||
required: true | ||
# And ouput one variable that will be available by the workflow | ||
outputs: | ||
filepath: | ||
description: "template archive path" | ||
value: ${{ steps.build.outputs.filepath }} | ||
runs: | ||
using: "composite" | ||
steps: | ||
# Ensure that zip is installed | ||
- run: sudo apt-get install zip | ||
shell: bash | ||
# Here we pass our inputs to the script.sh | ||
- id: build | ||
run: ${{ github.action_path }}/script.sh ${{inputs.project}} ${{inputs.tag}} | ||
shell: bash |
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,48 @@ | ||
#!/bin/bash | ||
|
||
DIRECTORY=`dirname $0` | ||
INPUT_PROJECT=$1 | ||
INPUT_TAG=$2 | ||
|
||
if [ -z $INPUT_PROJECT ] | ||
then | ||
echo "<project> missing" | ||
echo "Usage: ${0} <project> <tag>" | ||
exit 1 | ||
fi | ||
|
||
if [ -z $INPUT_TAG ] | ||
then | ||
echo "<tag> missing" | ||
echo "Usage: ${0} <project> <tag>" | ||
exit 1 | ||
fi | ||
|
||
# Set archive name from arguments | ||
ARCHIVE=template-${INPUT_PROJECT}-${INPUT_TAG}.zip | ||
|
||
echo "::group::building ${ARCHIVE}" | ||
echo "::debug::${ARCHIVE}" | ||
|
||
# zip sources template-${PROJECT}-${TAG}.zip | ||
zip -r ${ARCHIVE} . \ | ||
-x "dist/*" \ | ||
-x "node_modules/*" \ | ||
-x ".git/*" \ | ||
-x ".github/*" \ | ||
-x "docker-compose.yml" | ||
|
||
# Here we use echo to ouput the variables, usefull for to debug in github ui | ||
echo "$PWD" | ||
echo "$DIRECTORY" | ||
echo "$GITHUB_WORKSPACE" | ||
|
||
ls -lh $ARCHIVE | ||
|
||
echo "::endgroup::" | ||
|
||
echo "- ${INPUT_PROJECT^} ${INPUT_TAG} template built :rocket:" >> $GITHUB_STEP_SUMMARY | ||
|
||
# This step is important, it set the "filepath" output variable | ||
# Will be accessible in workflow | ||
echo "::set-output name=filepath::${ARCHIVE}" |
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,84 @@ | ||
name: deploy | ||
on: | ||
workflow_dispatch: | ||
push: | ||
paths-ignore: | ||
- 'README.md' | ||
- 'CHANGELOG.md' | ||
- 'LICENSE.md' | ||
branches: | ||
- main | ||
|
||
concurrency: | ||
group: ${{ github.workflow }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
docker-build: | ||
# We can skip deployment by adding [skip] in the commit body | ||
if: "!contains(github.event.head_commit.message, '[skip]')" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up dockertags | ||
run: | | ||
echo "dockertags=digisquad/cssninja.dokto-demo:latest" >> $GITHUB_ENV | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v3 | ||
timeout-minutes: 60 | ||
with: | ||
push: true | ||
tags: ${{ env.dockertags }} | ||
cache-from: type=registry,ref=${{ env.dockertags }} | ||
cache-to: type=inline | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: [docker-build] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Prepare | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USER }} | ||
key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
script_stop: true | ||
script: mkdir -p ${{ secrets.HOST_DIRECTORY }} | ||
|
||
- name: Publish | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USER }} | ||
key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
source: docker-compose.yml | ||
target: ${{ secrets.HOST_DIRECTORY }} | ||
|
||
- name: Deploy | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USER }} | ||
key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
script_stop: true | ||
script: | | ||
cd ${{ secrets.HOST_DIRECTORY }} | ||
docker-compose pull | ||
docker-compose up -d --force-recreate --remove-orphans |
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,85 @@ | ||
name: release | ||
on: | ||
# Automatically run when a semver tag is pushed | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
|
||
jobs: | ||
release: | ||
# setup strategy matrix, so we can share same pnpm cache | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
node-version: [18] | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
# Checkout action retreive the source (git clone) | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # needed to retreive all git history | ||
|
||
# Enable corepack, note that nodejs is already installed | ||
- run: corepack enable | ||
|
||
# Setup pnpm with cache | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: "pnpm" | ||
|
||
# Compute tag and capitalized product name | ||
- id: meta | ||
name: release meta | ||
run: | | ||
project=${GITHUB_REPOSITORY#*/} | ||
echo ::set-output name=project::${project} | ||
echo ::set-output name=project-capitalized::${project^} | ||
echo ::set-output name=tag::${GITHUB_REF#refs/tags/} | ||
# This is where we generate releases assets. | ||
# It use a github action in the current directory | ||
# which contains a shell script to create the archive. | ||
# The archive path is stored in the output action | ||
- id: build_template | ||
name: build release template | ||
uses: ./.github/actions/build-template-action | ||
with: | ||
tag: ${{ steps.meta.outputs.tag }} | ||
project: ${{ steps.meta.outputs.project }} | ||
|
||
# We re-generate the changelog using a subset of standard-version | ||
# The content is generated in a temp /CHANGELOG_RELEASE.md file | ||
# It is used to generate the body of the github release | ||
- id: changelog | ||
name: release changelog | ||
run: | | ||
pnpm dlx conventional-changelog-cli -p conventionalcommits -r 2 -o ${{ github.workspace }}/CHANGELOG_RELEASE.md | ||
cat ${{ github.workspace }}/CHANGELOG_RELEASE.md | ||
# Prepare the draft github release | ||
- id: create_release | ||
name: create github draft release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
# Use outputs from meta and changelog | ||
tag_name: ${{ steps.meta.outputs.tag }} | ||
name: ${{ steps.meta.outputs.project-capitalized }} ${{ steps.meta.outputs.tag }} | ||
body_path: ${{ github.workspace }}/CHANGELOG_RELEASE.md | ||
prerelease: false | ||
# The draft is required to allow file upload | ||
draft: true | ||
fail_on_unmatched_files: true | ||
# Here we bind files built by custom actions to the release | ||
files: | | ||
${{ github.workspace }}/${{ steps.build_template.outputs.filepath }} | ||
# Publish the github release | ||
# Dojo listen to those events | ||
- name: publish github draft release | ||
uses: eregon/publish-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.APP_GITHUB_TOKEN }} | ||
with: | ||
release_id: ${{ steps.create_release.outputs.id }} |
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,44 @@ | ||
name: standard-version | ||
on: | ||
# Allow to be manually dispatched | ||
workflow_dispatch: | ||
inputs: | ||
options: | ||
description: 'standard-version options' | ||
# Allow to be run via webhooks (Dojo will use this) | ||
repository_dispatch: | ||
types: [standard-version] | ||
|
||
jobs: | ||
standard-version: | ||
# setup strategy matrix, so we can share same pnpm cache | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
node-version: [18] | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
# Checkout action retreive the source (git clone) | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # needed to retreive all git history | ||
token: ${{ secrets.APP_GITHUB_TOKEN }} | ||
|
||
# Enable corepack, note that nodejs is already installed | ||
- run: corepack enable | ||
|
||
# Setup pnpm with cache | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: "pnpm" | ||
|
||
# Run "standard-version", which may create a new tag | ||
- run: | | ||
git config user.name digisquad-bot | ||
git config user.email admin@digisquad.io | ||
pnpm dlx standard-version ${{ github.event.inputs.options }} | ||
git push --follow-tags origin main | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.APP_GITHUB_TOKEN }} |
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,19 @@ | ||
FROM bitnami/node:18 AS build | ||
WORKDIR /app | ||
|
||
RUN corepack enable | ||
|
||
COPY package.json ./ | ||
COPY pnpm-lock.yaml ./ | ||
COPY .npmrc ./ | ||
RUN pnpm install --frozen-lockfile | ||
|
||
COPY . . | ||
RUN pnpm build | ||
|
||
|
||
FROM bitnami/nginx:1.22 AS prod | ||
WORKDIR /app | ||
|
||
COPY --from=build /app/dist . | ||
COPY ./nginx/alpinejs.conf /opt/bitnami/nginx/conf/server_blocks/nginx.conf |
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,23 @@ | ||
version: '3.7' | ||
|
||
services: | ||
dokto-demo: | ||
image: digisquad/cssninja.dokto-demo:latest | ||
networks: | ||
- cssninja-services | ||
restart: 'unless-stopped' | ||
labels: | ||
traefik.enable: true | ||
traefik.docker.network: 'cssninja-services' | ||
traefik.http.routers.dokto-demo.entrypoints: 'http' | ||
traefik.http.routers.dokto-demo.rule: 'Host(`dokto.${HOST:-127.0.0.1.nip.io}`)' | ||
traefik.http.routers.dokto-demo.middlewares: 'https-redirect@file' | ||
traefik.http.services.dokto-demo-https.loadbalancer.server.port: 8080 | ||
traefik.http.routers.dokto-demo-https.rule: 'Host(`dokto.${HOST:-127.0.0.1.nip.io}`)' | ||
traefik.http.routers.dokto-demo-https.tls: true | ||
traefik.http.routers.dokto-demo-https.entrypoints: 'https' | ||
traefik.http.routers.dokto-demo-https.tls.certresolver: 'http' | ||
|
||
networks: | ||
cssninja-services: | ||
external: true |
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,37 @@ | ||
server { | ||
listen 8080; | ||
server_name 0.0.0.0; | ||
error_page 500 502 503 504 /50x.html; | ||
charset utf-8; | ||
proxy_hide_header X-Frame-Options; | ||
add_header X-Frame-Options ""; | ||
|
||
# Media: images, icons, video, audio, HTC | ||
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|woff2)$ { | ||
expires 1y; | ||
access_log off; | ||
add_header Cache-Control "public"; | ||
} | ||
|
||
# CSS and Javascript | ||
location ~* \.(?:css|js)$ { | ||
expires 1y; | ||
access_log off; | ||
add_header Cache-Control "public"; | ||
} | ||
|
||
# Allow performing POST requests on static JSON files | ||
location ~* \.(?:json)$ { | ||
error_page 405 =200 $uri; | ||
} | ||
|
||
location / { | ||
root /app; | ||
index index.html; | ||
try_files $uri $uri/ /index.html; | ||
} | ||
|
||
location = /50x.html { | ||
root /usr/share/nginx/html; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "@cssninja/template", | ||
"name": "dokto", | ||
"type": "module", | ||
"version": "0.0.1", | ||
"private": true, | ||
|