Replace key on deploy #54
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: Dev-Deploy | |
# Trigger deployment only on push to master branch | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
env: | |
SSH_KEY: ${{secrets.SSH_KEY}} | |
VITE_SEARCHKIT_ENDPOINT: ${{secrets.VITE_SEARCHKIT_ENDPOINT}} | |
VITE_SEARCHKIT_API_KEY: ${{secrets.VITE_SEARCHKIT_API_KEY}} | |
VITE_SEARCHKIT_ENTITIES_INDEX: ${{secrets.VITE_SEARCHKIT_ENTITIES_INDEX}} | |
VITE_SEARCHKIT_LETTERS_INDEX: ${{secrets.VITE_SEARCHKIT_LETTERS_INDEX}} | |
VITE_API_ENDPOINT: ${{secrets.VITE_API_ENDPOINT}} | |
VITE_RECAPTCHA_API_KEY: ${{secrets.VITE_RECAPTCHA_API_KEY}} | |
REMOTE_USER: ${{secrets.REMOTE_USER}} | |
CAPTCHA_SECRET_KEY: ${{secrets.CAPTCHA_SECRET_KEY}} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set REMOTE_HOST for dev | |
if: endsWith(github.ref, '/develop') | |
run: echo "REMOTE_HOST=chercher.ecdsdev.org" >> $GITHUB_ENV | |
- name: Set REMOTE_HOST for prod | |
if: endsWith(github.ref, '/main') | |
run: echo "REMOTE_HOST=chercherbeckettletters.emory.edu" >> $GITHUB_ENV | |
- name: Use Node.js 16 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Add key to Captcha script | |
run: | | |
sed -i "s\<KEY>\\$CAPTCHA_SECRET_KEY\g" ./public/verifyCaptcha.php | |
- name: Install and Build | |
run: | | |
npm install | |
npm run build | |
- name: Set up Key | |
run: | | |
mkdir ~/.ssh | |
touch ~/.ssh/id_rsa | |
echo "$SSH_KEY" >> ~/.ssh/id_rsa | |
chmod 400 ~/.ssh/id_rsa | |
- name: Copy files to server | |
run: | | |
echo $REMOTE_HOST | |
rsync -aze "ssh -o StrictHostKeyChecking=no" dist/* $REMOTE_USER@$REMOTE_HOST:~/$REMOTE_HOST/ |