Merge pull request #91 from testsigmahq/dev #43
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: 'CD' | |
on: | |
push: | |
branches: | |
- 'main' | |
jobs: | |
Deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Update package information with default mirror | |
run: sudo sed -i 's|mirror+file:/etc/apt/apt-mirrors.txt|http://archive.ubuntu.com/ubuntu|' /etc/apt/sources.list && sudo apt-get update | |
- name: Install libvips | |
run: sudo apt-get install libvips | |
- uses: actions/checkout@v2 | |
- name: Setup Node 16 | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '16' | |
- name: Install dependencies | |
run: | | |
npm i --force --unsafe-perm | |
- name: Force installing sharp | |
run: npm install --ignore-scripts=false --verbose [email protected] --force --unsafe-perm | |
- name: 'Create env file' | |
run: | | |
rm -rf .env | |
touch .env | |
echo BUCKET_NAME=${{ secrets.BUCKET_NAME }} >> .env | |
echo HOST_NAME=${{ secrets.HOST_NAME }} >> .env | |
echo ASSET_HOST=${{ secrets.ASSET_HOST }} >> .env | |
echo FRESHCHAT_TOKEN=${{ secrets.FRESHCHAT_TOKEN }} >> .env | |
echo GA_TRACKING_ID=${{ secrets.GA_TRACKING_ID }} >> .env | |
echo GTAG_TRACKING_ID_FOR_GA4=${{ secrets.GTAG_TRACKING_ID_FOR_GA4 }} >> .env | |
echo GTAG_TRACKING_ID_FOR_GTAG=${{ secrets.GTAG_TRACKING_ID_FOR_GTAG }} >> .env | |
echo TYPESENSE_HOST=${{ secrets.TYPESENSE_HOST }} >> .env | |
echo TYPESENSE_PORT=${{ secrets.TYPESENSE_PORT }} >> .env | |
echo TYPESENSE_PROTOCOL=${{ secrets.TYPESENSE_PROTOCOL }} >> .env | |
echo TYPESENSE_COLLECTION=${{ secrets.TYPESENSE_COLLECTION }} >> .env | |
echo TYPESENSE_API_KEY=${{ secrets.TYPESENSE_API_KEY }} >> .env | |
echo TYPESENSE_SEARCH_API_KEY=${{ secrets.TYPESENSE_SEARCH_API_KEY }} >> .env | |
cat .env | |
- name: Build | |
run: | | |
PREFIX_PATHS=true npm run build && npm run deploy | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: 'us-east-1' | |
AWS_DEFAULT_OUTPUT: json | |
TYPESENSE_HOST: ${{ secrets.TYPESENSE_HOST }} | |
TYPESENSE_PORT: ${{ secrets.TYPESENSE_PORT }} | |
TYPESENSE_PROTOCOL: ${{ secrets.TYPESENSE_PROTOCOL }} | |
TYPESENSE_COLLECTION: ${{ secrets.TYPESENSE_COLLECTION }} | |
TYPESENSE_API_KEY: ${{ secrets.TYPESENSE_API_KEY }} | |
TYPESENSE_SEARCH_API_KEY: ${{ secrets.TYPESENSE_SEARCH_API_KEY }} | |
- name: Start Gatsby server | |
run: npm run develop & | |
env: | |
GATSBY_TELEMETRY_DISABLED: 1 | |
- name: Wait for Gatsby server to start | |
run: | | |
sleep 10 | |
until $(curl --output /dev/null --silent --head --fail http://localhost:8001); do | |
sleep 2 | |
done | |
- name: Run indexing script | |
run: npm run index | |
env: | |
TYPESENSE_HOST: ${{ secrets.TYPESENSE_HOST }} | |
TYPESENSE_PORT: ${{ secrets.TYPESENSE_PORT }} | |
TYPESENSE_PROTOCOL: ${{ secrets.TYPESENSE_PROTOCOL }} | |
TYPESENSE_COLLECTION: ${{ secrets.TYPESENSE_COLLECTION }} | |
TYPESENSE_API_KEY: ${{ secrets.TYPESENSE_API_KEY }} | |
TYPESENSE_SEARCH_API_KEY: ${{ secrets.TYPESENSE_SEARCH_API_KEY }} | |
- name: Stop Gatsby server | |
run: lsof -i :8001 -t | xargs kill |