Skip to content

Deploy main - Update product #12485

Deploy main - Update product

Deploy main - Update product #12485

Workflow file for this run

on:
push:
workflow_dispatch:
inputs:
build_id:
required: true
type: string
name: Publish to Cloudflare Pages
run-name: Deploy ${{ github.ref_name }} - ${{ github.event.head_commit.message || inputs.build_id }}
env:
STRAPI_URL: ${{ github.ref_name == 'main' && secrets.PROD_STRAPI_URL || secrets.DEV_STRAPI_URL }}
STRAPI_GRAPHQL_ENDPOINT: ${{ github.ref_name == 'main' && secrets.PROD_STRAPI_GRAPHQL_ENDPOINT || secrets.DEV_STRAPI_GRAPHQL_ENDPOINT }}
STRAPI_ACCESS_TOKEN: ${{ github.ref_name == 'main' && secrets.PROD_STRAPI_ACCESS_TOKEN || secrets.DEV_STRAPI_ACCESS_TOKEN }}
STRIPE_PUBLISHABLE_KEY: ${{ github.ref_name == 'main' && secrets.PROD_STRIPE_PUBLISHABLE_KEY || secrets.DEV_STRIPE_PUBLISHABLE_KEY }}
jobs:
publish:
name: Publish to Cloudflare Pages
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
steps:
- name: Confirm Build
if: always() && inputs.build_id
uses: webiny/[email protected]
with:
run: |
curl \
-H "Content-Type: application/json" \
-H "Build-Webhook-Secret: ${{ secrets.BUILD_WEBHOOK_SECRET }}" \
https://scripts.dilmahtea.me/confirm-build?ref=${{ github.ref_name }}
- name: Checkout
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Install pnpm
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: 9
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Restore astro-imagetools cache
uses: actions/cache/restore@v3
with:
path: node_modules/.cache/astro-imagetools
key: astro-imagetools-cache # this key is not used, it's just to make the action work
restore-keys: |
astro-imagetools-cache-
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build
- name: Generate astro-imagetools cache key
id: astro-imagetools-cache-key
if: always()
run: |
echo "key=astro-imagetools-cache-${{ github.ref_name }}-${{ hashFiles('node_modules/.cache/astro-imagetools/**') }}" >> $GITHUB_OUTPUT
- name: Save astro-imagetools cache
uses: actions/cache/save@v3
id: save-astro-imagetools-cache
if: always()
with:
path: node_modules/.cache/astro-imagetools
key: ${{ steps.astro-imagetools-cache-key.outputs.key }}
- name: Delete obsolete astro-imagetools caches
if: always()
run: |
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/dilmaheu/dilmahtea.me/actions/caches \
| jq -r '.actions_caches[] | select(.key | startswith("astro-imagetools-cache-${{ github.ref_name }}") and . != "${{ steps.astro-imagetools-cache-key.outputs.key }}") | .key' \
| while read -r key; do
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/dilmaheu/dilmahtea.me/actions/caches?key=$key
done
- name: Publish to Cloudflare Pages
timeout-minutes: 3
uses: cloudflare/pages-action@v1
with:
directory: dist
projectName: dilmahtea-me
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}