fix: Adopt common code March 2024 #69
Workflow file for this run
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: CI | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repo | |
- uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: print job details | |
run: | | |
echo "github_ref ${{ github.ref }}" | |
echo "github_event_name ${{ github.event_name }}" | |
- name: Cache npm dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} | |
- name: yarn install | |
run: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true yarn install --frozen-lockfile | |
- name: lint | |
run: yarn lint | |
- name: jest test | |
run: npm test | |
# snapshot-test: | |
# runs-on: ubuntu-latest | |
# steps: | |
# # Checkout the repo | |
# - uses: actions/checkout@v2 | |
# with: | |
# ref: ${{ github.head_ref }} | |
# - name: run snapshot tests | |
# run: | | |
# ./scripts/docker/prepare.sh | |
# ./scripts/docker/run-tests.sh | |
# - name: save snapshots | |
# if: failure() | |
# uses: actions/upload-artifact@v1 | |
# with: | |
# name: bitmaps_reference | |
# path: backstop_data/bitmaps_reference | |
deploy: | |
runs-on: ubuntu-latest | |
# needs: [test, snapshot-test] | |
needs: [test] | |
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' | |
steps: | |
# Checkout the repo | |
- uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: generate hash | |
run: | | |
HASH=$(date | md5sum | cut -d ' ' -f 1) | |
ZIP_FILE_NAME="isithappyhour.net---$HASH" | |
echo "HASH=$HASH" >> $GITHUB_ENV | |
echo "ZIP_FILE_NAME=$ZIP_FILE_NAME" >> $GITHUB_ENV | |
- name: install system dependencies | |
run: | | |
sudo apt-get update | |
sudo apt install -y qemu-user-static binfmt-support | |
- name: build docker image | |
env: | |
NODE_ENV: ${{ secrets.NODE_ENV }} | |
REDIS_URL: ${{ secrets.REDIS_URL }} | |
SECRET_API_KEY: ${{ secrets.SECRET_API_KEY }} | |
SESSION_SECRET: ${{ secrets.SESSION_SECRET }} | |
run: | | |
echo "zipFileName ${{ env.ZIP_FILE_NAME }}" | |
zipFileName=${{ env.ZIP_FILE_NAME }} | |
/bin/bash ./scripts/docker/export-prod.sh $zipFileName | |
- name: deploy | |
run: | | |
zipFileName=${{ env.ZIP_FILE_NAME }} | |
zip -r $zipFileName.zip docker-image.tar meta.json | |
echo "${{ secrets.EC2_RSA }}" > ./identityFile.txt | |
chmod 400 ./identityFile.txt | |
scp -o "StrictHostKeyChecking=no" -i ./identityFile.txt -r ./$zipFileName.zip [email protected]:/home/ubuntu/departure-lounge/ |