Skip to content

Commit

Permalink
ci: fix staging workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
thisyahlen-deriv committed Mar 25, 2024
1 parent 56efe79 commit 578adb5
Showing 1 changed file with 10 additions and 26 deletions.
36 changes: 10 additions & 26 deletions .github/workflows/build-and-deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ jobs:
build_to_cloudflare_pages:
timeout-minutes: 30
runs-on: ubuntu-latest
environment: staging
steps:
- name: Checkout to main branch
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18.x
node-version: 20.x
cache: 'npm'

- name: Get cached dependencies
Expand All @@ -45,27 +44,12 @@ jobs:
- name: Run unit tests and coverage report
run: npm run test

- name: Publish to Cloudflare Pages
id: publish-to-pages
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
HEAD_BRANCH: ${{ github.head_ref }}
run: |
echo "Installing Wrangler CLI"
npm i -g wrangler
echo "Deploying build to Cloudflare Pages"
directory='dist/'
projectName=${{ secrets.CLOUDFLARE_PROJECT_NAME }}
branch=$(echo "$HEAD_BRANCH" | head -c 20 | sed 's/[\/_\.]/-/g; s/[^a-zA-Z0-9]$/1/')
cf_preview_url=$(wrangler pages deploy $directory --project-name=$projectName --branch=$branch > log.txt 2>&1; echo $?)
echo "------"
preview_url=https://$branch.$projectName.pages.dev
cat log.txt
if grep -q "Deployment complete" log.txt; then
echo "preview_url=$preview_url" >> "$GITHUB_OUTPUT"
echo $preview_url > .pr/PREVIEW_URL
else
echo "Deployment to Cloudflare Pages failed."
exit 1
fi
- name: Publish to CF pages branch
id: publish_to_pages_branch
uses: "deriv-com/shared-actions/.github/actions/publish_to_pages_branch@v1"
with:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
project_name: "traders-hub"
branch_name: staging
output_dir: dist

0 comments on commit 578adb5

Please sign in to comment.