deploy action v8.1 #16
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
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | |
name: Deployment | |
on: | |
push: | |
branches: [ "develop" ] | |
pull_request: | |
branches: [ "develop" ] | |
workflow_dispatch: | |
jobs: | |
build: | |
name: build the project | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [16.x, 18.x] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
cache-dependency-path: | | |
client/package-lock.json | |
server/package-lock.json | |
- run: npm ci --force | |
working-directory: './client' | |
- run: npm run build | |
working-directory: './client' | |
- run: npm ci | |
working-directory: './server' | |
- run: npm run compile | |
working-directory: './server' | |
- name: Create directory structure for deployment | |
run: | | |
mkdir -p publikationsumgebung/client | |
mkdir -p publikationsumgebung/server | |
cp -r client/dist publikationsumgebung/client/ | |
cp -r server publikationsumgebung/ | |
working-directory: ${{ github.workspace }} | |
- name: Zip artifact for deployment | |
run: zip publikationsumgebung.zip ./publikationsumgebung -r | |
- name: Upload artifact for deployment job | |
uses: actions/upload-artifact@v3 | |
with: | |
name: development-artifact | |
path: /home/runner/work/socinian-graph-dse/socinian-graph-dse/publikationsumgebung.zip | |
deploy-dev: | |
name: deploy to development server | |
needs: [ build ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifact from build job | |
uses: actions/download-artifact@v3 | |
with: | |
name: development-artifact | |
- name: Install SSH Key | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: ${{secrets.SSH_KEY}} | |
known_hosts: ${{secrets.KNOWN_HOSTS}} | |
- name: ssh-scp-ssh-pipelines | |
uses: cross-the-world/[email protected] | |
with: | |
host: ${{secrets.SSH_HOST}} | |
user: ${{ secrets.SSH_USER }} | |
key: ${{secrets.SSH_KEY}} | |
first_ssh: | | |
cd ${{ secrets.SSH_PATH }} | |
pm2 delete --silent "GraphQL Dev" || : | |
rm -r * || : | |
scp: /home/runner/work/socinian-graph-dse/socinian-graph-dse/publikationsumgebung.zip => ${{ secrets.SSH_PATH }} # Warum ist der path geheim? | |
last_ssh: | | |
cd ${{ secrets.SSH_PATH }} | |
unzip publikationsumgebung.zip | |
pm2 start npm --name "GraphQL Dev" -- start | |
pm2 save |