feat: Update Dockerfile for multi-stage build and adjust Next.js outp… #6
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: Check Deploy Strategy | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| actions: write | |
| jobs: | |
| check-and-deploy: | |
| name: Check Deploy Strategy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Check DEPLOY_AWS secret | |
| id: check-deploy | |
| run: | | |
| if [ "${{ secrets.DEPLOY_AWS }}" == "true" ]; then | |
| echo "deploy_to_aws=true" >> $GITHUB_OUTPUT | |
| echo "Deploy to AWS ECS" | |
| else | |
| echo "deploy_to_aws=false" >> $GITHUB_OUTPUT | |
| echo "Deploy to GitHub Pages" | |
| fi | |
| - name: Trigger AWS Deployment | |
| if: steps.check-deploy.outputs.deploy_to_aws == 'true' | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'deploy.yml', | |
| ref: context.ref | |
| }); | |
| - name: Setup Node.js | |
| if: steps.check-deploy.outputs.deploy_to_aws == 'false' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: './aws-deploy-guide/package-lock.json' | |
| - name: Install dependencies | |
| if: steps.check-deploy.outputs.deploy_to_aws == 'false' | |
| working-directory: ./aws-deploy-guide | |
| run: npm ci | |
| - name: Build for GitHub Pages | |
| if: steps.check-deploy.outputs.deploy_to_aws == 'false' | |
| working-directory: ./aws-deploy-guide | |
| run: npm run build | |
| env: | |
| NEXT_PUBLIC_BASE_PATH: '' | |
| - name: Add .nojekyll file | |
| if: steps.check-deploy.outputs.deploy_to_aws == 'false' | |
| working-directory: ./aws-deploy-guide | |
| run: touch out/.nojekyll | |
| - name: Add CNAME file | |
| if: steps.check-deploy.outputs.deploy_to_aws == 'false' | |
| working-directory: ./aws-deploy-guide | |
| run: echo "devops4.himanmanduja.fun" > out/CNAME | |
| - name: Deploy to GitHub Pages | |
| if: steps.check-deploy.outputs.deploy_to_aws == 'false' | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./aws-deploy-guide/out | |
| cname: devops4.himanmanduja.fun |