Try to use npm to install railway/cli #98
This file contains 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: Deployments | |
on: | |
push: | |
branches: | |
- main | |
env: | |
CI: true | |
permissions: write-all | |
jobs: | |
create-release-pr: | |
name: Create release pr | |
timeout-minutes: 15 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Fetch tags | |
run: git fetch --tags origin | |
- name: Setup bun | |
uses: oven-sh/setup-bun@v1 | |
- name: Install dependencies | |
run: bun install | |
- name: Create release pr / create tags | |
id: changesets | |
uses: changesets/action@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
version: bun run version-packages | |
publish: bun run publish-packages | |
- name: Echo outputs | |
run: | | |
echo "hasChangesets=${{ steps.changesets.outputs.hasChangesets }}" | |
echo "publishedPackages=${{ steps.changesets.outputs.publishedPackages }}" | |
echo "publishedPackageNames=${{ toJSON(fromJSON(steps.changesets.outputs.publishedPackages).*['name']) }}" | |
outputs: | |
hasChangesets: ${{ steps.changesets.outputs.hasChangesets }} | |
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }} | |
publishedPackageNames: ${{ toJSON(fromJSON(steps.changesets.outputs.publishedPackages).*['name']) }} | |
publish-frontend: | |
needs: create-release-pr | |
name: Publish frontend | |
runs-on: ubuntu-latest | |
# 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/frontend') == true | |
# ) | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- 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: Deploy | |
run: railway up --service ${{ secrets.RAILWAY_FRONTEND_SERVICE_ID }} | |
env: | |
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }} | |
publish-backend: | |
needs: create-release-pr | |
name: Publish backend | |
runs-on: ubuntu-latest | |
# 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/backend') == true | |
# ) | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- 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: Deploy | |
run: railway up --service ${{ secrets.RAILWAY_BACKEND_SERVICE_ID }} | |
env: | |
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }} | |
cleanup-old-release-tags: | |
needs: create-release-pr | |
name: Cleanup old release tags | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
permissions: | |
contents: write | |
if: | | |
needs.create-release-pr.outputs.hasChangesets == 'false' && needs.create-release-pr.outputs.publishedPackages != '[]' | |
strategy: | |
matrix: | |
package: ${{ fromJSON(needs.create-release-pr.outputs.publishedPackages).*['name'] }} | |
steps: | |
- name: 'Delete release tags' | |
uses: jay2610/[email protected] | |
with: | |
keep_latest: 1 | |
delete_tags: true | |
delete_tag_pattern: ${{ matrix.package }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |