Skip to content

Merge branch 'main' of github.com:sandwichfarm/myrelay.site into main #1

Merge branch 'main' of github.com:sandwichfarm/myrelay.site into main

Merge branch 'main' of github.com:sandwichfarm/myrelay.site into main #1

Workflow file for this run

name: deploy
on: [push]
jobs:
write-to-console:
runs-on: ubuntu-latest
steps:
- name: build
with:
command: |
yarn install
yarn build
- name: get-npm-version
id: package-version
uses: martinbeentjes/[email protected]
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: 'sandwiches'
- name: Adding Known Hosts
run: ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
- name: check if remote file exists
uses: fifsky/ssh-action@master
id: version-exists
with:
command: |
if [ -f /var/www/html/${{ steps.package-version.outputs.current-version}} ]; then
exists=yes
else
exists=no
fi
echo "EXISTS=$exists" >> "$GITHUB_OUTPUT"
host: ${{ secrets.SSH_HOST }}
user: root
key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: fail if version exists
if: ${{ steps.version-exists.outputs.EXISTS == "yes" }}
with:
script: |
core.setFailed('/var/www/html/${{ steps.package-version.outputs.current-version}} already exists')
- name: Deploy with rsync
run: rsync -avz ./build/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/var/www/html/${{ steps.package-version.outputs.current-version}}
- name: Update symlink
run: ln -sf /var/www/html/${{ steps.package-version.outputs.current-version}} /var/www/html/latest