We use github actions to run all our deploys now. I have two issues:
-
All our deploy previews work fine but the branch deploy on development branch doesn’t work fine. Here is the branch -https://development--trace-client-v2.netlify.app/, it keeps redirecting to https://account-verification/. Yet the counterpart deploy link for the last build - https://66ae95943cf2b4ddc3b521e7--trace-client-v2.netlify.app/ works fine without any issues.
-
Some of the images linked from /public/assets folder no longer load.
Here is the workflow file that deploys to development branch
name: Deploy Development
on:
push:
branches:
- development
workflow_dispatch:
inputs:
branch:
description: “Branch to deploy”
required: true
default: “development”
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
app: [client, admin]
steps:
-
uses: actions/checkout@v4
with:
ref: ${{ github.sha }} -
name: Setup Node.js
uses: actions/setup-node@v4 -
name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9.1.3 -
name: Get pnpm cache directory path
id: pnpm-cache-dir-path
run: echo “dir=$(pnpm store path)” >> $GITHUB_OUTPUT -
uses: actions/cache@v4
id: pnpm-cache
with:
path: ${{ steps.pnpm-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-pnpm-${{ github.sha }}-${{ hashFiles(‘**/pnpm-lock.yaml’) }}
restore-keys: |
${{ runner.os }}-pnpm- -
uses: actions/cache@v4
id: next-cache
with:
path: apps/${{ matrix.app }}/.next
key: ${{ runner.os }}-next-${{ github.sha }}-${{ hashFiles(‘**/pnpm-lock.yaml’) }} -
name: Install dependencies
run: pnpm install -w -
name: Set netlify build variables
id: netlify-config
run: |
if [ “${{ matrix.app }}” == “client” ]; then
echo “NETLIFY_SITE_ID=${{ secrets.NETLIFY_TRACE_CLIENT_SITE_ID }}” >> $GITHUB_OUTPUT
echo “NETLIFY_PREVIEW_URL=https://development–trace-client-v2.netlify.app” >> $GITHUB_OUTPUT
elif [ “${{ matrix.app }}” == “admin” ]; then
echo “NETLIFY_SITE_ID=${{ secrets.NETLIFY_TRACE_ADMIN_SITE_ID }}” >> $GITHUB_OUTPUT
echo “NETLIFY_PREVIEW_URL=https://development–trace-admin-v2.netlify.app” >> $GITHUB_OUTPUT
fi -
name: Set Deploy Context
id: deploy-context
run: echo “DEPLOY_CONTEXT=dev” >> $GITHUB_OUTPUT -
name: Get last merged PR
id: get_pr
run: |
Fetch merged PRs
pr_data=$(gh pr list --state merged --base development --json number,title,mergedAt --limit 100)
Extract the last merged PR by sorting by mergedAt
pr_number=$(echo “$pr_data” | jq -r ‘sort_by(.mergedAt) | last | .number’)
pr_title=$(echo “$pr_data” | jq -r ‘sort_by(.mergedAt) | last | .title’)
echo “number=$pr_number” >> $GITHUB_OUTPUT
echo “title=$pr_title” >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and Deploy the app
id: deploy
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ steps.netlify-config.outputs.NETLIFY_SITE_ID }}
MESSAGE: “Merge pull request #${{ steps.get_pr.outputs.number }}: ${{ steps.get_pr.outputs.title }}”
DEPLOY_CONTEXT: ${{ steps.deploy-context.outputs.DEPLOY_CONTEXT }}
run: |
netlify deploy --build --filter ${{ matrix.app }} --context $DEPLOY_CONTEXT --dir apps/${{ matrix.app }}/.next --auth $NETLIFY_AUTH_TOKEN --site $NETLIFY_SITE_ID --alias development --message “$MESSAGE” -
name: Notify Slack on Success
if: success()
run: |
curl -X POST -H ‘Content-type: application/json’ --data ‘{
“text”: “ Deployment Successful! \n\nApp: '”${{ matrix.app }}"’\nEnvironment: ‘development’\nDetails: <‘“${{ steps.netlify-config.outputs.NETLIFY_PREVIEW_URL }}”’>"
}’ ${{ secrets.SLACK_WEBHOOK_URL }} -
name: Notify Slack on Failure
if: failure()
run: |
curl -X POST -H ‘Content-type: application/json’ --data ‘{
“text”: “ Deployment Failed! \n\nApp: '”${{ matrix.app }}"’\nEnvironment: ‘development’\nDetails: <‘“${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs”’|View Job>"
}’ ${{ secrets.SLACK_WEBHOOK_URL }}