#Deployment Steps

Perform the following steps from your terminal:

*
Device Authorization (prerequisite for new devices)

fridaybuilds_cli is a simple gem that provides authentication with your FridayBuilds account, directly from your terminal.

- Install fridaybuilds_cli gem

gem install fridaybuilds_cli

- Log in using your FridayBuilds credentials

GIT_ENDPOINT=https://staging-git.fridaybuilds.com friday login

The command above will try to open a browser window to the FridayBuilds CLI login page. If the page does not open automatically, your terminal will provide the url where you can log in.

After successfully logging in, the program will save the generated credentials to your .netrc file. You can manage these credentials on your account settings page.

You can add credentials manually to your .netrc file. The .netrc file is located, or should be created at ~/.netrc on Ubuntu, Mac or Windows WSL.

- Create a new Access Key

In the Account & Security tab on your Account & Billing page, click "New Access Key", then "Create Access Key". Reveal and copy the access key's "Content" field and use it in place of YOUR_ACCESS_KEY_CONTENT, in the template below. Replace YOUR_MAIL_ADDRESS with the mail you use to log in to FridayBuilds.

- Open .netrc file

nano ~/.netrc

- Add your credentials

# ~/.netrc
machine staging-git.fridaybuilds.com
  login YOUR_EMAIL_HERE
  password YOUR_ACCESS_KEY_CONTENT

- Save changes (ctrl+X to close file, then Y to save)


1 Add git remote

- Navigate to your project's directory.

- Make sure your project has an initialized git repository, with at least one commit.

- Add a git remote pointing to your fridaybuilds repository

              git remote add friday https://staging-git.fridaybuilds.com/YOUR_APP_SLUG.git
            
Optional

If you are working with a Procfile and want to run the migrations (or any other task) automatically when a new release is deployed, you can add a release command to your Procfile.

              # Procfile
              release: bundle exec rails db:migrate
            

Alternatively you can run commands on your app after deployment, via your app's Settings page.

2 Push your code
Before pushing (!)

Make sure your app has everything it needs to start — like a database (add one in the Resources tab) or ENV variables (set them in the Settings tab).

Then you can just push your code. The build process will be triggered only when pushing a main or master branch

git push friday main

The first time you deploy your app, FridayBuilds will issue an SSL Certificate for your app's default domain. When that process is complete, you can move on to run any final setup for your app.

Congrats! Your app should be deploying now. Your app's status is visible on the upper part of any app-related page.

If the deployment fails you can inspect the deployment log on the Activity page. After you fix any issues you can push again or rebuild manually from the Settings page.


#Environment variables

If your app needs specific environment variables to be set in order to work, you can add them from your app's Settings tab.

Click "Reveal" to start editing.

Use case (example)

For Rails apps for example you might need to add RAILS_MASTER_KEY, SECRET_KEY_BASE, RAILS_ENV and RACK_ENV. If using the mysql2 gem, you will need to add a mysql database service and then edit the DATABASE_URL to update the database protocol from `mysql:` to `mysql2:`.


#Remote Commands

You can run commands against your app's root directory (like you would in your local terminal) after the deployment is complete. You can do this from your app's Settings tab in two ways:

One-off commands

These commands run once and then terminate, returning the output of the command.

Interactive terminal

Spawn an interactive terminal session in your app's root directory. You can use this to run commands that require user input (like 'rails console' or 'bash').