Improve tests #189
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: Continuous Deployment | |
on: | |
push: | |
branches: | |
- 'production' | |
concurrency: | |
group: ci-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 14 | |
- uses: pnpm/[email protected] | |
name: Install pnpm | |
id: pnpm-install | |
with: | |
version: 7 | |
run_install: false | |
- name: Get pnpm store directory | |
id: pnpm-cache | |
run: | | |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install dependencies | |
run: pnpm install | |
- name: Run tests | |
run: pnpm test | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
needs: test | |
env: | |
SSH: ${{secrets.FRANKFURT_SSH}} | |
URL: [email protected] | |
ROOT: /var/www/admin.interflux.com | |
steps: | |
- uses: actions/checkout@v2 | |
# Create directory for SSH | |
- run: mkdir ~/.ssh | |
# Add the private key of the restricted bot user on the remote server | |
- run: 'echo "$SSH" > ~/.ssh/$URL' | |
# Configure SSH to always use the custom key, so we don't have to do ssh -i | |
- run: 'echo "IdentityFile ~/.ssh/$URL" > ~/.ssh/config' | |
# Add the remote server to trusted hosts | |
- run: ssh-keyscan -H frankfurt.server.interflux.com > ~/.ssh/known_hosts | |
# Set all SSH file permissions | |
- run: chmod 0755 ~/.ssh/; chmod 600 ~/.ssh/$URL; chmod 644 ~/.ssh/known_hosts | |
# First, check out the latest production branch on the remote. | |
- run: ssh $URL "cd $ROOT; git checkout production; git pull" | |
# Install Node and dependencies | |
- run: ssh $URL "cd $ROOT; nvm install; pnpm install" | |
# Build Ember app, once built Fastboot restarts | |
- run: ssh $URL "cd $ROOT; pnpm build" | |
# # For sanity checking the deploy we'll need pup to pull in interpet the live HTML | |
# - run: sudo apt-get install pup | |
# | |
# # The Git revision of this build | |
# - run: echo "BUILD_REVISION=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV | |
# | |
# # The Git revision currently live and served by Ember Fastboot | |
# - run: echo "LIVE_REVISION=$(curl 'https://new.interflux.com/en/product/IF-2005M' | pup 'meta[name="git-revision"] attr{content}')" | |
# | |
# # Fail the work flow, something is wrong. | |
# - name: 'Sanity check: FAIL' | |
# run: exit -1 | |
# if: env.BUILD_REVISION != env.LIVE_REVISION | |
# | |
# # All green, deploy was successful! | |
# - name: 'Sanity check: PASS' | |
# if: env.BUILD_REVISION == env.LIVE_REVISION | |
# run: exit 0 |