Skip to content

Commit

Permalink
Trying deploy by editing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
akadeepesh committed Jul 5, 2024
1 parent c832cb8 commit 9d42211
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 134 deletions.
87 changes: 0 additions & 87 deletions .github/workflows/branch_deploy.yml

This file was deleted.

97 changes: 50 additions & 47 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,76 +17,79 @@ concurrency:
cancel-in-progress: false

jobs:
build:
build-main:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest

steps:
- name: Checkout
- name: Checkout main
uses: actions/checkout@v4

- name: Detect project type
id: detect-project
run: |
if [ -f "${{ github.workspace }}/next.config.js" ]; then
echo "type=nextjs" >> $GITHUB_OUTPUT
else
echo "type=static" >> $GITHUB_OUTPUT
fi
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=yarn" >> $GITHUB_OUTPUT
elif [ -f "${{ github.workspace }}/package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
else
echo "manager=none" >> $GITHUB_OUTPUT
echo "command=none" >> $GITHUB_OUTPUT
echo "runner=none" >> $GITHUB_OUTPUT
fi
- name: Setup Node
if: steps.detect-project.outputs.type == 'nextjs'
uses: actions/setup-node@v4
with:
node-version: "20"
cache: ${{ steps.detect-package-manager.outputs.manager }}

- name: Setup Pages
uses: actions/configure-pages@v1
with:
static_site_generator: ${{ steps.detect-project.outputs.type == 'nextjs' && 'next' || 'static' }}

- name: Install dependencies
if: steps.detect-package-manager.outputs.manager != 'none'
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
run: npm ci

- name: Build project
- name: Build Next.js
run: |
if [ "${{ steps.detect-project.outputs.type }}" = "nextjs" ]; then
${{ steps.detect-package-manager.outputs.runner }} next build
${{ steps.detect-package-manager.outputs.runner }} next export
fi
npm run build
npm run export
env:
NEXT_PUBLIC_BASE_PATH: ${{ format('/BioSignal-Recorder-Web{0}', github.ref == 'refs/heads/main' && '' || format('/{0}', github.ref_name)) }}
NEXT_PUBLIC_BASE_PATH: /BioSignal-Recorder-Web

- name: Upload artifact
- name: Upload main artifact
uses: actions/upload-pages-artifact@v3
with:
path: ${{ steps.detect-project.outputs.type == 'nextjs' && './out' || '.' }}
name: main-build
path: ./out

build-version1:
runs-on: ubuntu-latest
steps:
- name: Checkout version1.0
uses: actions/checkout@v4
with:
ref: version1.0

- name: Upload version1.0 artifact
uses: actions/upload-pages-artifact@v3
with:
name: version1-build
path: .

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
needs: [build-main, build-version1]
steps:
- name: Download main artifact
uses: actions/download-artifact@v3
with:
name: main-build
path: ./main-build

- name: Download version1 artifact
uses: actions/download-artifact@v3
with:
name: version1-build
path: ./version1-build

- name: Merge artifacts
run: |
mkdir -p ./merged
cp -R ./main-build/* ./merged/
mkdir -p ./merged/version1.0
cp -R ./version1-build/* ./merged/version1.0/
- name: Upload merged artifact
uses: actions/upload-pages-artifact@v2
with:
path: ./merged

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

0 comments on commit 9d42211

Please sign in to comment.