Skip to content

Deploy production

Deploy production #200

Workflow file for this run

name: Deploy production
# Controls when the action will run. Triggers the workflow on push
# events but only for the master branch
on:
push:
branches: [ master ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest # The type of runner that the job will run on
steps: # Steps represent a sequence of tasks that will be executed as part of the job
- uses: actions/checkout@v2 # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Enter data to .env file
run: |
echo FLOTIQ_BASE_URL=https://api.flotiq.com >> .env.production
echo FLOTIQ_API_KEY="$FLOTIQ_API_KEY" >> .env.production
echo SCOPED_FLOTIQ_API_KEY="$SCOPED_FLOTIQ_API_KEY" >> .env.production
echo GA_MEASUREMENT_ID="$GA_MEASUREMENT_ID" >> .env.production
shell: bash
env:
FLOTIQ_API_KEY: ${{ secrets.FLOTIQ_API_KEY }}
SCOPED_FLOTIQ_API_KEY: ${{ secrets.SCOPED_FLOTIQ_API_KEY }}
GA_MEASUREMENT_ID: ${{ secrets.GA_MEASUREMENT_ID }}
- uses: actions/setup-node@v1
with:
node-version: '16'
- run: yarn install
- name: Gatsby
run: |
npm install -g [email protected]
gatsby clean
gatsby build
# rm -rf public/blog
# mkdir -p public/blog
# find public/ -maxdepth 1 -mindepth 1 -not -name blog -exec mv '{}' public/blog/ \;
# find public/blog -name index.html -exec sed -i 's\window.pagePath="\window.pagePath="/blog\g' {} \;
- name: Cloudflare
run: |
npm install -g wrangler
wrangler init --site flotiq-blog
sed -i 's+account_id = '\'\''+account_id = '"'"$ACCOUNT_ID"'"'+g' wrangler.toml
sed -i 's+bucket = ""+bucket = "public"+g' wrangler.toml
sed -i 's+zone_id = '\'\''+zone_id = '"'"$ZONE_ID"'"'+g' wrangler.toml
sed -i 's+workers_dev = true++g' wrangler.toml
echo "[env.production]" >> wrangler.toml
echo "routes = [{ pattern = 'blog.flotiq.com', custom_domain = true }]" >> wrangler.toml
mkdir -p /home/runner/.wrangler/config/
echo api_token = '"'"$API_TOKEN"'"' > /home/runner/.wrangler/config/default.toml
cat wrangler.toml
cp worker-index.js workers-site/index.js
wrangler publish --env=production
# Refresh sitemap in Google and Bing
curl "https://www.google.com/webmasters/sitemaps/ping?sitemap=https://blog.flotiq.com/sitemap/sitemap-index.xml"
curl "https://www.bing.com/webmaster/ping.aspx?siteMap=https://blog.flotiq.com/sitemap/sitemap-index.xml"
shell: bash
env:
API_TOKEN: ${{ secrets.API_TOKEN }}
ACCOUNT_ID: ${{ secrets.ACCOUNT_ID }}
ZONE_ID: ${{ secrets.ZONE_ID }}