Skip to content

Fix #1288 admin/refresh-invoices background thread with app context #287

Fix #1288 admin/refresh-invoices background thread with app context

Fix #1288 admin/refresh-invoices background thread with app context #287

Workflow file for this run

---
# When a push is made to a branch, deploy an instance of the app using
# that branch.
# The deployed url will be <branchname>.<domain>
name: Recording demo videos
on:
push:
branches:
- master
paths-ignore:
- '**/README.md'
- '**/TESTING.md'
- 'docs/**'
workflow_dispatch:
jobs:
demo-videos:
runs-on: ubuntu-22.04
timeout-minutes: 60
environment: testing
steps:
- name: Dump context
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: |
echo $GITHUB_CONTEXT
- name: Prepare runner with ssh keys
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
DOKKU_HOST: ${{ secrets.DOKKU_HOST }}
run: |
set -x
mkdir -p ~/.ssh
eval `ssh-agent -s`
ssh-add - <<< "$SSH_PRIVATE_KEY"
ssh-keyscan $DOKKU_HOST >> ~/.ssh/known_hosts
- name: Set subdomain (ensure is lowercase for dokku)
run: |
set -x
echo SUBDOMAIN=`echo "${{ github.event.repository.default_branch }}" | tr '[:upper:]' '[:lower:]' | cut -c -60` >> $GITHUB_ENV
echo $GITHUB_ENV
- name: Create dokku app for pr branch if dosent already exist using dokku apps:create
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
DOKKU_HOST: ${{ secrets.DOKKU_HOST }}
run: |
set -x
echo The PR was raised by: ${{ github.event.pull_request.user.login }}
eval `ssh-agent -s`
ssh-add - <<< "$SSH_PRIVATE_KEY"
echo Creating dokku app ${{ github.event.repository.default_branch }}
ssh dokku@$DOKKU_HOST -C "dokku apps:create ${{ env.SUBDOMAIN }}" | true
echo The url will be ${{ github.event.repository.default_branch }}.pcpink.co.uk
ssh dokku@$DOKKU_HOST -C "dokku git:initialize ${{ env.SUBDOMAIN }}"
ssh dokku@$DOKKU_HOST -C "dokku git:set ${{ env.SUBDOMAIN }} deploy-branch ${{ github.event.repository.default_branch }}"
# set Stripe test keys as env vars dor dokku/docker
ssh dokku@$DOKKU_HOST -C "dokku config:set --no-restart ${{ env.SUBDOMAIN }} STRIPE_TEST_SECRET_KEY=${{ secrets.STRIPE_TEST_SECRET_KEY }}"
ssh dokku@$DOKKU_HOST -C "dokku config:set --no-restart ${{ env.SUBDOMAIN }} STRIPE_TEST_PUBLISHABLE_KEY=${{ secrets.STRIPE_TEST_PUBLISHABLE_KEY }}"
ssh dokku@$DOKKU_HOST -C "dokku config:set --no-restart ${{ env.SUBDOMAIN }} STRIPE_CONNECT_ACCOUNT_ANNOUNCER_HOST=${{ secrets.STRIPE_CONNECT_ACCOUNT_ANNOUNCER_HOST }}"
ssh dokku@$DOKKU_HOST -C "dokku config:set --no-restart ${{ env.SUBDOMAIN }} FLASK_ENV=development"
ssh dokku@$DOKKU_HOST -C "dokku config:set --no-restart ${{ env.SUBDOMAIN }} EMAIL_QUEUE_FOLDER=${{ secrets.DOKKU_EMAIL_QUEUE_FOLDER }}"
# mount email-queue folder
ssh dokku@$DOKKU_HOST -C "dokku storage:mount ${{ env.SUBDOMAIN}} ${{ secrets.HOST_EMAIL_QUEUE_PATH }}:${{ secrets.DOKKU_EMAIL_QUEUE_FOLDER }} && dokku ps:restart ${{ env.SUBDOMAIN }} || true"
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Deploy branch ${{ github.event.repository.default_branch }} to dokku
uses: idoberko2/dokku-deploy-github-action@v1
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
dokku-host: ${{ secrets.DOKKU_HOST }}
app-name: ${{ env.SUBDOMAIN }}
git-push-flags: '--force'
remote-branch: ${{ github.event.repository.default_branch }}
- uses: actions/setup-node@v3
- uses: microsoft/playwright-github-action@v1
- name: Install node dependencies needed for Playwright browser tests
run: |
npm i -D @playwright/test@1.27.1
npx playwright install
sudo npx playwright install-deps
- name: Run & Record browser automated tests (Playwright)
env:
PLAYWRIGHT_HOST: http://${{ github.event.repository.default_branch }}.pcpink.co.uk/
PLAYWRIGHT_SLOWMO: 1000
PLAYWRIGHT_HEADLESS: true
SUBSCRIBER_EMAIL_HOST: ${{ secrets.SUBSCRIBER_EMAIL_HOST }}
SUBSCRIBER_EMAIL_USER: ${{ secrets.SUBSCRIBER_EMAIL_USER }}
SUBSCRIBER_EMAIL_PASSWORD: ${{ secrets.SUBSCRIBER_EMAIL_PASSWORD }}
EMAIL_SEARCH_API_HOST: ${{ secrets.EMAIL_SEARCH_API_HOST }}
RESET_PASSWORD_IMAP_SEARCH_SUBJECT: ${{ secrets.RESET_PASSWORD_IMAP_SEARCH_SUBJECT }}
IMAP_SEARCH_UNSEEN: "1"
IMAP_SEARCH_SINCE_DATE: "01-Jun-2022"
run: |
set -x
cp tests/browser-automated-tests-playwright/.env.example tests/browser-automated-tests-playwright/.env
cp .env.example .env
cd tests/browser-automated-tests-playwright
python3 run-playwright-tests.py
- name: upload videos to site
run: |
set -x
mkdir -p ~/.ssh
eval `ssh-agent -s`
ssh-add - <<< "${{ secrets.SUBWEBBUILD_PRIVATE_KEY }}"
ssh-keyscan ${{secrets.ONBOARDING_HOST}} >> ~/.ssh/known_hosts
scp -Cr ./tests/browser-automated-tests-playwright/test-videos/* ${{secrets.SUBWEBBUILD_USER}}@${{secrets.ONBOARDING_HOST}}:${{secrets.ONBOARDING_VIDEOS_PATH}}
- name: Organise videos into list on webpage
run: |
# Organise playwright videos into a single
# directory list of webm videos with name:
# <issue-number>-<usertype>-<description>.webm
# Video may be seen at https://subscriptionwebsitebuilder.co.uk/videos/output/
set -x
mkdir -p ~/.ssh
eval `ssh-agent -s`
ssh-add - <<< "${{ secrets.SUBWEBBUILD_PRIVATE_KEY }}"
ssh-keyscan ${{secrets.ONBOARDING_HOST}} >> ~/.ssh/known_hosts
ssh ${{secrets.SUBWEBBUILD_USER}}@${{secrets.ONBOARDING_HOST}} -C "cd ${{secrets.ONBOARDING_VIDEOS_PATH}};./process.py"
echo "🙌 Videos available: https://subscriptionwebsitebuilder.co.uk/videos/output/"