Merge pull request #13 from USTakAssociation/update-deps #78
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: Playtak API service deploy Dev | |
on: | |
push: | |
branches: [ dev ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: Beta | |
strategy: | |
matrix: | |
node-version: [22.x] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- run: npm ci | |
- name: Lint code | |
run: npm run lint | |
- name: Run Unit tests | |
run: npm run test | |
- name: Build | |
env: | |
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} | |
run: | | |
mkdir -p ./src/assets/ | |
touch ./src/assets/client_secret.json | |
echo -n "${CLIENT_SECRET}" >> ./src/assets/client_secret.json | |
npm run build | |
- name: Prep Artifact | |
env: | |
PORT : ${{ secrets.PORT }} | |
NODE_ENV: ${{ secrets.NODE_ENV }} | |
CORS_DOMAIN: ${{ secrets.CORS_DOMAIN }} | |
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} | |
ANON_DB_PATH: ${{ secrets.ANON_DB_PATH }} | |
DB_PATH: ${{ secrets.DB_PATH }} | |
APP_ENV: ${{ secrets.APP_ENV }} | |
PREVIOUS_FILE: ${{ secrets.PREVIOUS_FILE }} | |
RATING_OUTPUT_PATH: ${{ secrets.RATING_OUTPUT_PATH }} | |
RATING_CRON_VALUE: ${{ secrets.RATING_CRON_VALUE }} | |
run : | | |
rm .env | |
touch .env | |
echo "PORT = ${PORT}" >> .env | |
echo "NODE_ENV = ${NODE_ENV}" >> .env | |
echo "CORS_DOMAIN = ${CORS_DOMAIN}" >> .env | |
echo "ANON_DB_PATH = ${ANON_DB_PATH}" >> .env | |
echo "DB_PATH = ${DB_PATH}" >> .env | |
echo "APP_ENV = ${APP_ENV}" >> .env | |
echo "PREVIOUS_FILE = ${PREVIOUS_FILE}" >> .env | |
echo "RATING_OUTPUT_PATH = ${RATING_OUTPUT_PATH}" >> .env | |
echo "RATING_CRON_VALUE = ${RATING_CRON_VALUE}" >> .env | |
mv .env ./dist | |
mv node_modules ./dist | |
mv previous.txt ./dist | |
tar -czf artifact.tar.gz ./dist | |
- name: Deploy | |
env: | |
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} | |
HOSTNAME : ${{ secrets.HOSTNAME }} | |
USER_NAME : ${{ secrets.USER_NAME }} | |
SSH_PORT: ${{ secrets.SSH_PORT }} | |
run: | | |
echo "$PRIVATE_KEY" > private_key.pem && chmod 0400 private_key.pem | |
scp -P ${SSH_PORT} -o StrictHostKeyChecking=no -i private_key.pem artifact.tar.gz ${USER_NAME}@${HOSTNAME}:~ | |
ssh -p ${SSH_PORT} -o StrictHostKeyChecking=no -i private_key.pem ${USER_NAME}@${HOSTNAME} ' | |
source ~/.nvm/nvm.sh | |
rm -rf playtak-api-dev-tmp | |
mkdir playtak-api-dev-tmp | |
tar -xzf artifact.tar.gz -C ./playtak-api-dev-tmp | |
cp /var/apps/playtak-api-beta/previous.txt playtak-api-dev-tmp/previous.txt | |
sudo rm -rf /var/apps/playtak-api-beta | |
sudo mv playtak-api-dev-tmp/dist/ /var/apps/playtak-api-beta | |
cp playtak-api-dev-tmp/previous.txt /var/apps/playtak-api-beta/previous.txt | |
rm -rf playtak-api-dev-tmp | |
rm artifact.tar.gz | |
pm2 restart playtak-api-prod --update-env --interpreter=/home/ubuntu/.nvm/versions/node/v22.11.0/bin/node | |
' |