diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index aba318f..bc915a0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,7 +2,9 @@ name: Deploy on: push: - branches: [ main ] + branches: + - main + workflow_dispatch: {} jobs: deploy: @@ -11,55 +13,13 @@ jobs: id-token: write contents: read steps: - - name: Checkout code - uses: actions/checkout@v4.2.2 - - name: Install Node.js - run: | - curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - - sudo apt-get install -y nodejs - echo /opt/hostedtoolcache/node/22.10.0/x64/bin >> $GITHUB_PATH - - name: Check node - run: | - ls -alFh /opt/hostedtoolcache/node/ - echo $PATH - which node - which npm - node -v - npm -v - - name: Restore NPM node_modules - uses: actions/cache/restore@v4.1.2 + - name: Next JS Build and Deploy + uses: p6m7g8-actions/next-deploy@main with: - path: node_modules - key: ${{ runner.os }}-node_modules-${{ hashFiles('pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-node_modules- - - name: Install pnpm and dependencies - run: | - corepack enable - corepack prepare pnpm@latest --activate - pnpm install - - name: Cache NPM dependencies - uses: actions/cache@v4.1.2 - with: - path: node_modules - key: ${{ runner.os }}-node_modules-${{ hashFiles('pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-node_modules- - - name: Disable Next.js Telemetry - run: echo "NEXT_TELEMETRY_DISABLED=1" >> "$GITHUB_ENV" - - name: Run build - run: pnpm run build - - name: Assume role using OIDC - uses: aws-actions/configure-aws-credentials@v4.0.2 - with: - aws-region: ${{ secrets.CDK_DEPLOY_REGION }} - role-to-assume: ${{ secrets.AWS_ROLE }} - role-session-name: ${{ secrets.AWS_SESSION_NAME }} - - name: Deploy to S3 - run: aws s3 sync out s3://${{ secrets.BUCKET_NAME }} --no-progress --follow-symlinks --delete --region ${{ secrets.CDK_DEPLOY_REGION }} - - name: Invalidate CloudFront cache - uses: chetan/invalidate-cloudfront-action@v2.4 - env: - AWS_REGION: ${{ secrets.CDK_DEPLOY_REGION }} - DISTRIBUTION: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} - PATHS: '/*' \ No newline at end of file + aws_region: ${{ secrets.CDK_DEPLOY_REGION }} + aws_role: ${{ secrets.AWS_ROLE }} + aws_session_name: ${{ secrets.AWS_SESSION_NAME }} + cdk_deploy_account: ${{ secrets.CDK_DEPLOY_ACCOUNT }} + cdk_deploy_region: ${{ secrets.CDK_DEPLOY_REGION }} + bucket_name: ${{ secrets.BUCKET_NAME }} + cloudfront_distribution_id: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} \ No newline at end of file