Test Deploy #15
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
name: Deploy | ||
on: | ||
pull_request: | ||
branches: | ||
- develop | ||
env: | ||
PUBLIC: "~/motsflex/public" | ||
ASSETS: "$PUBLIC/assets" | ||
INDEX_HTML: "$PUBLIC/index.html" | ||
DICOS: "~/dicos" | ||
SERVER: "~/motsflex/server.js" | ||
SSH_TARGET: ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_HOST }} | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "16" | ||
- name: Install Dependencies | ||
run: npm install | ||
- name: Build | ||
run: npm run build | ||
- name: Determine Deployment Type | ||
if: success() && steps.install_dependencies.outcome == 'success' && steps.build.outcome == 'success' | ||
run: | | ||
Check failure on line 37 in .github/workflows/deploy.yml GitHub Actions / DeployInvalid workflow file
|
||
LABELS=$(toJson(github.event.pull_request.labels.*.name)) | ||
echo "DEPLOY_ASSETS=${{ contains(LABELS, 'deploy:assets') }}" >> $GITHUB_ENV | ||
echo "DEPLOY_SERVER=${{ contains(LABELS, 'deploy:server') }}" >> $GITHUB_ENV | ||
echo "DEPLOY_CLIENT=${{ contains(LABELS, 'deploy:client') }}" >> $GITHUB_ENV | ||
- name: Deploy | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
echo "Github ref: $GITHUB_REF" | ||
if [[ "${{ env.DEPLOY_ASSETS }}" == 'true' ]]; then | ||
echo "Deploying JS assets" | ||
ssh $SSH_TARGET "rm -rf $ASSETS && mkdir -p $ASSETS" | ||
scp -r dist/public/assets $SSH_TARGET:$ASSETS | ||
scp -r dist/public/index.html $SSH_TARGET:$INDEX_HTML | ||
fi | ||
if [[ "${{ env.DEPLOY_CLIENT }}" == 'true' ]]; then | ||
echo "Deploying full client" | ||
ssh $SSH_TARGET "rm -rf $PUBLIC && mkdir -p $PUBLIC" | ||
scp -r dist/public $SSH_TARGET:$PUBLIC | ||
ssh $SSH_TARGET "cp $DICOS/*.zip $ASSETS" | ||
fi | ||
if [[ "${{ env.DEPLOY_SERVER }}" == 'true' ]]; then | ||
echo "Deploying server code" | ||
scp -r dist/server.js $SSH_TARGET:$SERVER | ||
fi |