Skip to content

Commit

Permalink
Test Deploy (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo-Nicolle authored Feb 15, 2024
1 parent 62bcafb commit c7656f0
Show file tree
Hide file tree
Showing 135 changed files with 30,440 additions and 8,253 deletions.
31 changes: 0 additions & 31 deletions .github/workflows/ci.yml

This file was deleted.

75 changes: 75 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Deploy

on:
pull_request:
types: [closed]

jobs:
deploy:
if: github.event.pull_request.merged == true || github.ref_name == 'master'
runs-on: ubuntu-latest
env:
TARGET: ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_HOST }}
KEY: /tmp/private-key
DIR: ~/motsflex
DICOS: ~/dicos
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
ref: "develop"
- name: Setup ssh
run: |
mkdir -p ~/.ssh/ && touch ~/.ssh/known_hosts
ssh-keyscan ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts
echo "${{ secrets.SSH_PRIVATE_KEY }}" > $KEY
chmod 600 $KEY
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"

- name: Determine Deployment Type
if: ${{ success() }}
run: |
echo "DEPLOY_ASSETS=${{ contains(toJson(github.event.pull_request.labels.*.name), 'deploy:assets') }}" >> $GITHUB_ENV
echo "DEPLOY_SERVER=${{ contains(toJson(github.event.pull_request.labels.*.name), 'deploy:server') }}" >> $GITHUB_ENV
echo "DEPLOY_CLIENT=${{ contains(toJson(github.event.pull_request.labels.*.name), 'deploy:client') }}" >> $GITHUB_ENV
echo "PUBLIC=$DIR/public" >> $GITHUB_ENV
echo "SERVER=${{ env.DIR }}/server.js" >> $GITHUB_ENV
echo "ASSETS=${{ env.DIR }}/public/assets" >> $GITHUB_ENV
echo "INDEX_HTML=${{ env.DIR }}/public/index.html" >> $GITHUB_ENV
if [[ $DEPLOY_ASSETS == 'false' && $DEPLOY_SERVER == 'false' && $DEPLOY_CLIENT == 'false' ]]; then
exit 1;
fi
- name: Install Dependencies
if: ${{ success() }}
run: npm ci

- name: Build
if: ${{ success() }}
run: npm run build

- name: Deploy
if: ${{ success() }}
run: |
if [ "$DEPLOY_ASSETS" = 'true' ]; then
echo "Deploying JS assets"
ssh -i $KEY $TARGET "rm -rf $ASSETS && mkdir -p $ASSETS"
scp -i $KEY -r dist/public/assets/* "$TARGET:$ASSETS"
scp -i $KEY -r dist/public/index.html "$TARGET:$INDEX_HTML"
fi
if [ "$DEPLOY_CLIENT" = 'true' ]; then
echo "Deploying full client"
ssh -i $KEY $TARGET "rm -rf $PUBLIC && mkdir -p $PUBLIC"
scp -i $KEY -r dist/public/* "$TARGET:$PUBLIC"
ssh -i $KEY $TARGET "cp $DICOS/*.zip $PUBLIC/assets"
fi
if [ "$DEPLOY_SERVER" = 'true' ]; then
echo "Deploying server code"
scp -i $KEY -r dist/server.js "$TARGET:$SERVER"
fi
- name: Cleanup
run: "rm -f $KEY && rm -rf ~/.ssh"
29 changes: 29 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Deploy

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ develop ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Deploy using ssh
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
script: |
cd /tmp/mots-fleches
git pull origin develop
git status
npm install
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
client/node_modules/
client/dist/
client/public/result*
client/public/allwords*
client/public/allwords*
client/public/test-db.json
client/reports/
server/node_modules
server/dist
Expand All @@ -13,3 +14,4 @@ build/
dist/
docs/.vuepress/.cache
docs/.vuepress/.temp
scripts/api-key.mjs
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# MotsFLex
# MotsFlex

![MotsFlex logo](./client/public/icon.svg | width=100)
<a href="https://motsflex.com">
<img alt="Logo" align="center" src="./client/public/icon.svg" width="20%" />
</a>

**Generateur de mots fléchés. Crosswords generator. Generator de Crucigramas.**

Expand Down
12 changes: 1 addition & 11 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,9 @@
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Pacifico&family=Roboto:wght@500&display=swap" rel="stylesheet">

<script defer data-domain="motsflex.com" src="/js/script.js"></script>
<title>Mots Flex</title>
<style>
@font-face {
font-family: "VeganStyle";
src: local("VeganStyle"),
url(./VeganStyle.ttf) format("truetype");
}
@font-face {
font-family: "KeyNormal";
src: local("KeyNormal"),
url(./KeyNormal.ttf) format("truetype");
}
</style>
</head>

Expand Down
Loading

0 comments on commit c7656f0

Please sign in to comment.