fix #15
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 Preview | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- README.md | |
- CHANGELOG.md | |
- MIT-LICENSE | |
- .env | |
- doc/** | |
- bin/** | |
- .vscode/** | |
- .gitignore | |
jobs: | |
deploy_preview: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
deployments: write | |
name: Publish to Cloudflare Pages | |
timeout-minutes: 10 | |
environment: | |
name: preview | |
url: https://redirectchecker-preview.pages.dev/ | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: npm install | |
- name: Deploy to Cloudflare Pages | |
run: | | |
response=$(curl -s -o /dev/null -w "%{http_code}" -X GET "https://api.cloudflare.com/client/v4/accounts/${{ secrets.CLOUDFLARE_ACCOUNT_ID }}/pages/projects/redirectchecker-preview" \ | |
-H "Authorization: Bearer ${{ secrets.CLOUDFLARE_API_TOKEN }}") | |
if [ $response -eq 404 ]; then | |
echo "Project does not exist, creating..." | |
npx wrangler pages project create redirectchecker-preview --production-branch main | |
else | |
echo "Project exists, skipping creation." | |
fi | |
sed -i 's/redirectchecker/redirectchecker-preview/' wrangler.toml | |
npm run pages:build && npx wrangler pages deploy --branch main | |
env: | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |