Skip to content

Test Deploy

Test Deploy #44

Workflow file for this run

name: Deploy
on:
pull_request:
branches:
- develop
jobs:
deploy:
runs-on: ubuntu-latest
env:
TARGET: ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_HOST }}
KEY: /tmp/private-key
PUBLIC: "~/motsflex-save/public"
ASSETS: "${{env.PUBLIC}}/assets"

Check failure on line 15 in .github/workflows/deploy.yml

View workflow run for this annotation

GitHub Actions / Deploy

Invalid workflow file

The workflow is not valid. .github/workflows/deploy.yml (Line: 15, Col: 15): Unrecognized named-value: 'env'. Located at position 1 within expression: env.PUBLIC .github/workflows/deploy.yml (Line: 16, Col: 19): Unrecognized named-value: 'env'. Located at position 1 within expression: env.PUBLIC
INDEX_HTML: "${{env.PUBLIC}}/index.html"
DICOS: "~/dicos"
SERVER: "~/motsflex-save/server.js"
# if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- 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
# if [[ ${{env.DEPLOY_ASSETS}} ='false' && ${{env.DEPLOY_SERVER}} ='false' && ${{env.DEPLOY_CLIENT}} ='false' ]]; then
# exit 1;
# fi
- name: Install Dependencies
if: ${{ success() }}
run: npm install
- 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
# scp "${{ env.SSH }} "
# rm -rf $PUBLIC/assets && mkdir -p $PUBLIC/assets
# cp -r dist/public/assets $PUBLIC/assets
# cp -r dist/public/index.html $PUBLIC/index.html
fi
# if [ "$DEPLOY_CLIENT" = 'true' ]; then
# echo "Deploying full client"
# rm -rf $PUBLIC && mkdir -p $PUBLIC
# cp -r dist/public $PUBLIC
# cp $DICOS/*.zip $PUBLIC/assets
# fi
# if [ "$DEPLOY_SERVER" = 'true' ]; then
# echo "Deploying server code"
# cp -r dist/server.js $SERVER
# fi
- name: Cleanup
run: "rm -f $KEY && rm -rf ~/.ssh"
# - name: Deploy
# uses: appleboy/ssh-action@master
# env:
# DEPLOY_ASSETS: "${{ env.DEPLOY_ASSETS }}"
# DEPLOY_SERVER: "${{ env.DEPLOY_SERVER }}"
# DEPLOY_CLIENT: "${{ env.DEPLOY_CLIENT }}"
# with:
# host: ${{ secrets.SERVER_HOST }}
# username: ${{ secrets.SERVER_USERNAME }}
# key: ${{ secrets.SSH_PRIVATE_KEY }}
# port: 22
# envs: DEPLOY_ASSETS,DEPLOY_SERVER,DEPLOY_CLIENT,PUBLIC,ASSETS,INDEX_HTML,DICOS,SERVER
# script: |
# cd ~/tmp/mots-fleches
# git pull origin develop
# npm install
# npm run build
# if [ "$DEPLOY_ASSETS" = 'true' ]; then
# echo "Deploying JS assets"
# rm -rf $ASSETS && mkdir -p $ASSETS
# cp -r dist/public/assets $ASSETS
# cp -r dist/public/index.html $INDEX_HTML
# fi
# if [ "$DEPLOY_CLIENT" = 'true' ]; then
# echo "Deploying full client"
# rm -rf $PUBLIC && mkdir -p $PUBLIC
# cp -r dist/public $PUBLIC
# cp $DICOS/*.zip $ASSETS
# fi
# if [ "$DEPLOY_SERVER" = 'true' ]; then
# echo "Deploying server code"
# cp -r dist/server.js $SERVER
# fi