diff --git a/.github/workflows/railway-preview.yml b/.github/workflows/railway-preview.yml index dcb21cb..e39144b 100644 --- a/.github/workflows/railway-preview.yml +++ b/.github/workflows/railway-preview.yml @@ -22,41 +22,39 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Deploy to Railway Preview - id: deploy + - name: Deploy to Railway uses: ayungavis/railway-preview-deploy@v1.0.2 with: railway_api_token: ${{ secrets.RAILWAY_API_TOKEN }} project_id: ${{ secrets.RAILWAY_PROJECT_ID }} environment_name: 'production' - preview_environment_name: 'pr-${{ github.event.pull_request.number }}-${{ github.sha }}' + preview_environment_name: 'pr-${{ github.event.pull_request.number }}' + environment_variables: | + { + "DATABASE_URL": "postgres://username:password@hostname/db" + } branch_name: ${{ github.head_ref }} - reuse_preview_environment: 'true' - name: Post deployment info - if: ${{ steps.deploy.outputs.service_domain != '' }} - run: | - echo "🚀 Preview deployed at: ${{ steps.deploy.outputs.service_domain }}" - echo "Preview URL: https://${{ steps.deploy.outputs.service_domain }}" + run: + echo "Preview deployed at ${{ steps.deploy.outputs.service_domain }}" - name: Post or update deployment comment - if: ${{ steps.deploy.outputs.service_domain != '' }} + if: ${{ steps.test-action.outputs.service_domain != '' }} uses: actions/github-script@v7 with: script: | - const marker = ''; - + const marker = ''; // Unique marker to identify the comment const { data: commits } = await github.rest.pulls.listCommits({ owner: context.repo.owner, repo: context.repo.repo, pull_number: context.issue.number, - per_page: 1 + per_page: 100 }); - const latestCommit = commits[commits.length - 1]; const latestCommitSha = latestCommit.sha.substring(0, 7); const latestCommitAuthor = latestCommit.commit.author.name; - const latestCommitMessage = latestCommit.commit.message.split('\n')[0]; + const { data: comments } = await github.rest.issues.listComments({ issue_number: context.issue.number, @@ -65,23 +63,18 @@ jobs: }); const body = ` - ${marker} - ## 🚀 Railway Preview Deployment + ${marker} + 🚀 **Deployment success!** - **Preview URL:** [https://${{ steps.deploy.outputs.service_domain }}](https://${{ steps.deploy.outputs.service_domain }}) + - \`web\` deployed at [${{ steps.test-action.outputs.service_domain }}](https://${{ steps.test-action.outputs.service_domain }}) --- - - **Latest commit:** \`${latestCommitSha}\` - **Author:** ${latestCommitAuthor} - **Message:** ${latestCommitMessage} - - *This preview environment will be automatically cleaned up when the PR is closed or merged.* + + *commit: ${latestCommitSha}* + *author: ${latestCommitAuthor}* `; - const existingComment = comments.find(comment => - comment.user.type === 'Bot' && comment.body.includes(marker) - ); + const existingComment = comments.find(comment => comment.body.includes(marker)); if (existingComment) { await github.rest.issues.updateComment({ @@ -90,7 +83,7 @@ jobs: repo: context.repo.repo, body: body }); - console.log(`Updated comment ID: ${existingComment.id}`); + core.info(`Updated comment ID: ${existingComment.id}`); } else { await github.rest.issues.createComment({ issue_number: context.issue.number, @@ -98,24 +91,25 @@ jobs: repo: context.repo.repo, body: body }); - console.log('Created a new comment'); + core.info('Created a new comment'); } cleanup: runs-on: ubuntu-latest - if: ${{ github.event.pull_request.merged == true || github.event.action == 'closed' }} + if: + ${{ github.event.pull_request.merged == true || github.event.action == + 'closed' }} steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Cleanup Railway Preview Environment + - name: Cleanup Railway Environment uses: ayungavis/railway-preview-deploy@v1.0.2 with: railway_api_token: ${{ secrets.RAILWAY_API_TOKEN }} project_id: ${{ secrets.RAILWAY_PROJECT_ID }} - environment_name: 'production' + environment_name: production preview_environment_name: 'pr-${{ github.event.pull_request.number }}' branch_name: ${{ github.head_ref }} - cleanup: 'true' - + cleanup: 'true' \ No newline at end of file diff --git a/src/app.controller.ts b/src/app.controller.ts new file mode 100644 index 0000000..6202e57 --- /dev/null +++ b/src/app.controller.ts @@ -0,0 +1,9 @@ +import { Controller, Get } from '@nestjs/common'; + +@Controller() +export class AppController { + @Get() + getHello(): string { + return 'hello'; + } +} diff --git a/src/app.module.ts b/src/app.module.ts index f96d2ed..9a12e8f 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -4,6 +4,7 @@ import { UserModule } from './user/user.module'; import { BookmarkModule } from './bookmark/bookmark.module'; import { PrismaModule } from './prisma/prisma.module'; import { ConfigModule } from '@nestjs/config'; +import { AppController } from './app.controller'; @Module({ imports: [ @@ -11,5 +12,6 @@ import { ConfigModule } from '@nestjs/config'; isGlobal: true }), AuthModule, UserModule, BookmarkModule, PrismaModule], + controllers: [AppController], }) export class AppModule {} diff --git a/src/main.ts b/src/main.ts index a4261f8..3371e6e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,5 +8,6 @@ async function bootstrap() { whitelist: true })); const port = process.env.PORT || 3333; + await app.listen(port); } bootstrap();