Version 28 #1184
Workflow file for this run
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
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
deployments: write | |
name: Publish to Cloudflare Pages | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Set DUO_WEB_VERSION | |
id: vars | |
run: | | |
calculated_sha=$(git rev-parse --short HEAD) | |
echo "DUO_WEB_VERSION=$calculated_sha" >> $GITHUB_ENV | |
- uses: actions/setup-node@v4 | |
- run: | | |
npm install | |
npx patch-package | |
npx expo export --platform web | |
if ! patch -p0 < patches/index.html.patch | |
then | |
echo dist/index.html.rej was > /dev/stderr | |
cat dist/index.html.rej > /dev/stderr | |
echo | |
echo dist/index.html was > /dev/stderr | |
cat dist/index.html > /dev/stderr | |
exit 1 | |
fi | |
cat > dist/_headers <<EOF | |
/* | |
X-Frame-Options: DENY | |
Access-Control-Allow-Origin: ${DUO_API_URL} | |
EOF | |
# Cloudflare ignores directories containing the string 'node_modules'. | |
# Expo generates directories containing the string 'node_modules'. | |
# We rename the directories so that they're not ignored and get | |
# uploaded. | |
mv dist/assets/node_modules/* dist/assets/ | |
find dist/_expo/static/js/web/ -type f -print0 | xargs -0 sed -i 's/assets\/node_modules/assets/g' | |
env: | |
NODE_OPTIONS: --openssl-legacy-provider | |
DUO_API_URL: https://api.duolicious.app | |
DUO_CHAT_URL: wss://chat.duolicious.app | |
DUO_IMAGES_URL: https://user-images.duolicious.app | |
DUO_AUDIO_URL: https://user-audio.duolicious.app | |
DUO_STATUS_URL: https://status.duolicious.app | |
DUO_WEB_BASE_URL: https://web.duolicious.app | |
- uses: cloudflare/pages-action@v1 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: a73a8f703a9a1eefac56f84ca6a4c9ac | |
projectName: duolicious | |
directory: dist |