Skip to content

trigger-deploy

trigger-deploy #1309

Workflow file for this run

name: Deploy
on:
workflow_dispatch:
repository_dispatch:
types: [ trigger-deploy ]
push:
branches:
- main
- dev
pull_request:
branches:
- dev
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Deploy to Cloudflare Pages
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: '26'
- name: Install dependencies
run: npm ci
- name: Generate i18n files
run: npm run i18n:extract
- name: Configure Umami
run: |
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
UMAMI_ID="0d563b9d-f076-4a41-b4c6-1afd4e3f2c0f"
else
# Non production deployment
UMAMI_ID="87620d09-e7f3-4d2d-bc7a-2af95d7775ea"
fi
# The data-website-id in the source code is now just a placeholder
# and will be replaced during the build process.
sed -i "s/const WEBSITE_ID = '[^']*'/const WEBSITE_ID = '$UMAMI_ID'/" public/js/analytics.js
- name: Generate robots.txt
# Don't allow indexing of non-production deployments.
run: |
if [ "${{ github.ref }}" != "refs/heads/main" ]; then
echo -e "User-agent: *\nDisallow: /" > public/robots.txt
fi
- name: Generate Changelog HTML
run: |
echo "Generating changelog..."
node scripts/generate-changelog.js
echo "Changelog generated"
- name: Fetch and Update Morphe Download Link
run: |
MANAGER_PROPS_URL="https://raw.githubusercontent.com/MorpheApp/morphe-manager/refs/heads/main/app-release.json"
VERSION=$(curl -s "$MANAGER_PROPS_URL" | jq -r '.version')
if [ -z "$VERSION" ]; then
echo "Error: Could not find version string in gradle.properties." >&2
exit 1
fi
DOWNLOAD_URL="https://github.com/MorpheApp/morphe-manager/releases/download/v$VERSION/morphe-manager-$VERSION.apk"
# Update index.html with the download link
sed -i "s|DOWNLOAD_URL_TEMPLATE|$DOWNLOAD_URL|g" public/index.html
echo "Updated index.html with Morphe download link."
- name: Fetch and Update MicroG Download Link
run: |
MICROG_BUILD_GRADLE_URL="https://raw.githubusercontent.com/MorpheApp/MicroG-RE/refs/heads/main/build.gradle"
# parse out "ext.appVersionName = x.xx"
VERSION=$(curl -s $MICROG_BUILD_GRADLE_URL | grep "appVersionName" | head -n 1 | cut -d '=' -f 2 | tr -d " '\"[:space:]")
if [ -z "$VERSION" ]; then
echo "Error: Could not find appVersionName in build.gradle." >&2
exit 1
fi
DOWNLOAD_URL="https://github.com/MorpheApp/MicroG-RE/releases/download/$VERSION/microg-$VERSION.apk"
# Update microg.html with the download link
sed -i "s|DOWNLOAD_URL_TEMPLATE|$DOWNLOAD_URL|g" public/microg.html
echo "Updated public/microg.html with MicroG download link."
# Must inline first then minify
- name: Inline HTML/CSS/JS
run: npm run inline
- name: Minify HTML/CSS/JS
run: npm run minify
- name: Install Wrangler
run: npm install -g wrangler
- name: Deploy with Wrangler
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: wrangler pages deploy --branch "${{ github.ref_name }}" --commit-dirty=true