Deploy production #267
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: Deploy production | |
# Controls when the action will run. Triggers the workflow on push | |
# events but only for the master branch | |
on: | |
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 | |
- name: Fail if not on master branch | |
if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/master' | |
run: | | |
echo "This workflow should only run from master branch" | |
exit 1 | |
- 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 | |
echo GTM_ID="$GTM_ID" >> .env.production | |
echo POST_STATUSES=public >> .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 }} | |
GTM_ID: ${{ secrets.GTM_ID }} | |
- uses: actions/setup-node@v1 | |
with: | |
node-version: '20' | |
- run: yarn install | |
- name: Gatsby | |
run: | | |
npm install -g gatsby-cli@5.13.2 | |
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 Deploy | |
uses: cloudflare/wrangler-action@v3 | |
with: | |
apiToken: ${{ secrets.API_TOKEN }} | |
accountId: ${{ secrets.ACCOUNT_ID }} | |
environment: production | |
- name: After deployment scripts | |
run: | | |
# 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" | |