diff --git a/.github/workflows/aws-static.yml b/.github/workflows/aws-static.yml new file mode 100644 index 00000000..c7883c0c --- /dev/null +++ b/.github/workflows/aws-static.yml @@ -0,0 +1,69 @@ +name: Deploy Next.js to AWS S3 + +on: + pull_request: + branches: [ "main" ] + paths: + - .github/workflows/aws-static.yml + - client/** + - assistant/** + +env: + AWS_REGION: ${{ vars.AWS_REGION }} + NEXT_PUBLIC_API_DOMAIN: ${{ vars.NEXT_PUBLIC_API_DOMAIN }} + AMPLIFY_APP_ID: ${{ vars.AMPLIFY_APP_ID }} + S3_BUCKET: ${{ vars.S3_BUCKET }} + NEXT_STANDALONE: "true" + +permissions: + id-token: write + contents: read + +jobs: + deploy: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18.x] + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Cache node modules + uses: actions/cache@v2 + with: + path: client/node_modules + key: ${{ runner.os }}-node-${{ hashFiles('client/**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Node ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: arn:aws:iam::654654285942:role/Github-OIDC + audience: sts.amazonaws.com + aws-region: ${{ env.AWS_REGION }} + + - name: Install Dependencies + run: npm install + working-directory: ./client + + - name: Build Amplify App + run: npm run build + working-directory: ./client + + - name: Upload Build to S3 + working-directory: ./client + run: | + find out -type f -name '*.html' | while read file; do + cp "$file" "${file%.html}" + done + aws s3 sync ./out s3://${{ env.S3_BUCKET }} --content-type 'text/html' + + diff --git a/client/app/factory/edit/page.tsx b/client/app/factory/edit/page.tsx index acdaf292..26da9085 100644 --- a/client/app/factory/edit/page.tsx +++ b/client/app/factory/edit/page.tsx @@ -53,11 +53,11 @@ export default function Edit() { const [gitUrl, setGitUrl] = React.useState(''); const apiDomain = process.env.NEXT_PUBLIC_API_DOMAIN; - useEffect(() => { - if (!user || status !== 'success' || user.id.startsWith('client|')) { - router.push(`${apiDomain}/api/auth/login`); - } - }, [user, status]); + // useEffect(() => { + // if (!user || status !== 'success' || user.id.startsWith('client|')) { + // router.push(`${apiDomain}/api/auth/login`); + // } + // }, [user, status]); const { updateBot: onUpdateBot, diff --git a/client/app/factory/list/components/BotCard.tsx b/client/app/factory/list/components/BotCard.tsx index 36c5fb71..347f4171 100644 --- a/client/app/factory/list/components/BotCard.tsx +++ b/client/app/factory/list/components/BotCard.tsx @@ -113,7 +113,7 @@ const BotCard = (props: { bot: Bot }) => { }} > {I18N.components.BotCard.tiaoShi} router.push(`/factory/edit?id=${bot.id}`)} className="z-10 cursor-pointer" @@ -135,7 +135,7 @@ const BotCard = (props: { bot: Bot }) => { }} > {I18N.components.BotCard.gengXinZhiShi} diff --git a/client/components/BotCard.tsx b/client/components/BotCard.tsx index 2e72dc60..b5e58365 100644 --- a/client/components/BotCard.tsx +++ b/client/components/BotCard.tsx @@ -41,7 +41,7 @@ const BotCard = (props: {
- +
diff --git a/client/next.config.js b/client/next.config.js index 21fb5224..f2af2e89 100644 --- a/client/next.config.js +++ b/client/next.config.js @@ -6,7 +6,7 @@ const { withSentryConfig } = require("@sentry/nextjs"); const nextConfig = { - ...process.env.NEXT_STANDALONE ? { output: "standalone" } :{}, + ...process.env.NEXT_STANDALONE ? { output: "export", ssr: false } :{}, webpack: (config, { dev}) => { config.resolve.fallback = { http: false, https: false, net: false, tls: false }; @@ -32,7 +32,7 @@ module.exports = withSentryConfig(nextConfig, { silent: false, // Can be used to suppress logs hideSourceMaps: true, - + sourcemaps: { disable: true, },