forked from komali2/quick-taiwan-conversions
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Deploy Prod | ||
|
||
# ----- | ||
# This workflow will run whenever changes are pushed to main | ||
# ----- | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
env: | ||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | ||
SSH_HOST: ${{ secrets.SSH_HOST }} | ||
SSH_PORT: ${{ secrets.SSH_PORT }} | ||
SSH_USERNAME: ${{ secrets.SSH_USERNAME }} | ||
jobs: | ||
deploy: | ||
name: Deploy | ||
environment: prod | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repository code | ||
uses: actions/checkout@v3 | ||
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." | ||
- name: List files in the repository | ||
run: | | ||
ls ${{ github.workspace }} | ||
- uses: actions/download-artifact@v2 | ||
- name: Copy bleck into id rsa | ||
run: install -m 600 -D /dev/null ~/.ssh/id_rsa | ||
- name: See if env vars propagated | ||
run: echo "$SSH_HOST" | ||
- name: Copy private key into keyfile | ||
run: echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa | ||
- name: Scan into known hosts | ||
run: ssh-keyscan -H -p "$SSH_PORT" "$SSH_HOST" > ~/.ssh/known_hosts | ||
- name: Send updated source to our VPS | ||
run: rsync -rav --delete -e 'ssh -i ~/.ssh/id_rsa -p 3732' ${{ github.workspace }}/ "$SSH_USERNAME"@"$SSH_HOST":/home/"$SSH_USERNAME"/src/quick-taiwan-conversions/ | ||
- name: Build new prod | ||
run: ssh -p 3732 "${SSH_USERNAME}"@"${SSH_HOST}" "cd src/quick-taiwan-conversions && npm install && npm run build" | ||
- name: Move build files to web directory | ||
run: ssh -p 3732 "${SSH_USERNAME}"@"${SSH_HOST}" "cd src/quick-taiwan-conversions && rsync -a --chown=${SSH_USERNAME}:www-data dist/. /home/www-data/converter/" |