From f607ba97f1b25dd2e1e913ff51b07c5af69e5c36 Mon Sep 17 00:00:00 2001 From: Thomas Moore Date: Mon, 16 Oct 2023 20:23:08 +0100 Subject: [PATCH] Deployments to railway prod on outputs --- .github/workflows/deployments.yml | 68 ++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 15 deletions(-) diff --git a/.github/workflows/deployments.yml b/.github/workflows/deployments.yml index 40b1cfe..ef3099f 100644 --- a/.github/workflows/deployments.yml +++ b/.github/workflows/deployments.yml @@ -44,25 +44,63 @@ jobs: publishedPackages: ${{ steps.changesets.outputs.publishedPackages }} publishedPackageNames: ${{ toJSON(fromJSON(steps.changesets.outputs.publishedPackages).*['name']) }} - deploy: + publish-frontend: needs: create-release-pr - name: Deploy check + name: Publish frontend runs-on: ubuntu-latest + env: + RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }} + if: | + needs.create-release-pr.outputs.hasChangesets == 'false' && ( + contains(needs.create-release-pr.outputs.publishedPackageNames, '@haishin/tsconfig') == true || + contains(needs.create-release-pr.outputs.publishedPackageNames, '@haishin/utils') == true || + contains(needs.create-release-pr.outputs.publishedPackageNames, '@haishin/transcriber') == true || + contains(needs.create-release-pr.outputs.publishedPackageNames, '@haishin/frontend') == true + ) steps: - - name: Check for changesets - if: needs.create-release-pr.outputs.hasChangesets == 'true' - run: exit 1 - - name: Check for published packages - if: | - !( - contains(needs.create-release-pr.outputs.publishedPackageNames, '@haishin/tsconfig') == true || - contains(needs.create-release-pr.outputs.publishedPackageNames, '@haishin/utils') == true || - contains(needs.create-release-pr.outputs.publishedPackageNames, '@haishin/backend') == true || - contains(needs.create-release-pr.outputs.publishedPackageNames, '@haishin/frontend') == true - ) - run: exit 1 + - name: Setup bun + uses: oven-sh/setup-bun@v1 + + - name: Install dependencies + run: bun install + + - name: Install Railway + run: npm i -g @railway/cli + + - name: Set service + run: railway service frontend + + - name: Deploy + run: railway up + + publish-backend: + needs: create-release-pr + name: Publish backend + runs-on: ubuntu-latest + env: + RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }} + if: | + needs.create-release-pr.outputs.hasChangesets == 'false' && ( + contains(needs.create-release-pr.outputs.publishedPackageNames, '@haishin/tsconfig') == true || + contains(needs.create-release-pr.outputs.publishedPackageNames, '@haishin/utils') == true || + contains(needs.create-release-pr.outputs.publishedPackageNames, '@haishin/transcriber') == true || + contains(needs.create-release-pr.outputs.publishedPackageNames, '@haishin/backend') == true + ) + steps: + - name: Setup bun + uses: oven-sh/setup-bun@v1 + + - name: Install dependencies + run: bun install + + - name: Install Railway + run: npm i -g @railway/cli + + - name: Set service + run: railway service backend + - name: Deploy - run: exit 0 + run: railway up cleanup-old-release-tags: needs: create-release-pr