Automated Deployments for Node.js Apps with Github Actions and Railway
Published: 2023-05-23 23:59:56

## What I built
I built a task manager that helps keep track of your tasks. It helps to:
- Users can create, edit, and delete tasks.
- Users can assign tasks to themselves or to other users.
- Users can view a list of all their tasks.
- Users can view a list of all their tasks that are due today.
- Users can view a list of all their tasks that are overdue.

### Category Submission: *DIY Deployments*

### App Link: [Live Link](https://vestal-grade-production.up.railway.app/api)

### Screenshots

![Documentation Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e39qwa86meubthxm7ynn.png)

[Link to Documentation](https://documenter.getpostman.com/view/14599476/2s93m4Y3XM)

### Description
A Task Manager for keeping track of pending, in-progress, or completed tasks. 

### Link to Source Code 
[Code on GitHub](https://github.com/olumidayy/task-on)

### Permissive License 
[Link To License](https://github.com/olumidayy/task-on/blob/main/LICENSE)

## Background (What made you decide to build this particular app? What inspired you?)
I recently started working with GitHub actions for continuous integration and I stumbled upon this hackathon. I saw this as opportunity to work on using Gihub Actions for Automatic deployments.

### How I built it (How did you utilize GitHub Actions or GitHub Codespaces? Did you learn something new along the way? Pick up a new skill?) 
I used GitHub for both Continuous Integration and Deployment/Delivery. As can be seen in the workflow file, [main.yml](https://github.com/olumidayy/task-on/blob/main/.github/workflows/main.yml), Github Actions helps to install dependencies, test the code, and push changes to the remote server. This saves developers the hassle of manual deployments and cuts delivery time considerably. It also helped me learn a new way to utilize Github actions the right way. 

```yml
name: Node.js CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3
      - name: Use Node.js 16
        uses: actions/setup-node@v3
        with:
          node-version: 16
          cache: 'npm'

      - name: Install Dependencies
        run: npm i

      - name: Run Tests
        run: npm t

      - name: Fix Linting Issues
        run: npm run lint:fix

      - name: Install Railway
        run: npm i -g @railway/cli

      - name: Deploy
        run: railway up
        env:
          RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
```
A few reasons why this is helpful and should be normal practice are:
- It provides faster feedback on code changes, allowing for issues to be caught and fixed earlier in the development process.
- It improves the reliability of products by catching errors and bugs before they reach production.
- It  encourages collaboration between developers, testers, and other stakeholders, leading to a more effective development process.
- It improves security by automatically running security tests and scans as part of the development process.
- It increases agility by allowing developers to quickly make code changes and deploy them to production.