chore: update CI #4
This file contains hidden or 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 - nextjs | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - testnet | |
| - beta | |
| jobs: | |
| nextjs: | |
| runs-on: ubuntu-latest | |
| env: | |
| VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
| VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
| VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18 | |
| - name: Extract branch name | |
| shell: bash | |
| id: extract_branch | |
| run: | | |
| branch=$(echo ${GITHUB_REF#refs/heads/}) | |
| echo "branch=$branch" >> $GITHUB_OUTPUT | |
| - name: save env variable | |
| id: saveEnv | |
| run: echo "NEXT_PUBLIC_GIT_REF=${{ steps.extract_branch.outputs.branch }}" > .env | |
| - run: cat .env | |
| - name: get isProd | |
| id: isProd | |
| uses: notiz-dev/github-action-json-property@release | |
| with: | |
| path: "./deploy.json" | |
| prop_path: "${{ steps.extract_branch.outputs.branch }}.isProd" | |
| - name: get alias | |
| id: alias | |
| uses: notiz-dev/github-action-json-property@release | |
| with: | |
| path: "./deploy.json" | |
| prop_path: "${{ steps.extract_branch.outputs.branch }}.alias" | |
| - name: "Install vercel" | |
| run: npm i -g vercel | |
| - name: "Deploy to vercel" | |
| id: deploy | |
| run: | | |
| prodRun="" | |
| if [[ ${{steps.isProd.outputs.prop}} == "true" ]]; then | |
| prodRun="--prod" | |
| fi | |
| echo $prodRun | |
| deployment_url=$(vercel --confirm -t $VERCEL_TOKEN --scope $VERCEL_ORG_ID $prodRun) | |
| echo "DEPLOYMENT_URL=$deployment_url" >> $GITHUB_OUTPUT | |
| echo "Deployment URL: $deployment_url" | |
| - name: "Set alias" | |
| run: | | |
| echo ${{steps.alias.outputs.prop}} | |
| vercel alias set ${{ steps.deploy.outputs.DEPLOYMENT_URL }} ${{steps.alias.outputs.prop}} -t $VERCEL_TOKEN --scope $VERCEL_ORG_ID |