DEV Community

Shivam Agarwal
Shivam Agarwal

Posted on • Updated on

A Step-by-Step Guide to Using Spheron's GitHub Actions

Warning: This post contains a high dose of code, humor, and life-changing revelations. Proceed at your own risk. 😎

When people ask me how to use spheron's github actions, I usually reply with "build a dapp." But recently, I decided to put that statement to the test by providing step-by-step solution on how to use spheron's github actions.

In this roller-coaster ride of an article, we'll build elucidate in 4 steps.

🙅‍♂️ Let's dive into some intro stuff!

Introduction🔥

GitHub Actions is a powerful tool that can transform the way you manage your software projects. It allows you to automate various workflows, from continuous integration to continuous deployment (CI/CD), directly within your GitHub repository. In this comprehensive guide, we will delve deep into the world of GitHub Actions and show you how to leverage Spheron's GitHub Actions for effortless project deployment. Whether you're a seasoned developer or just starting, this step-by-step tutorial will provide you with the knowledge you need to streamline your development process.

Prerequisites

Before we embark on this journey, let's ensure you have everything you need to get started:

  1. A GitHub account: If you don't already have one, sign up for a GitHub account. GitHub is a platform where you can host your code repositories and collaborate with others.

  2. A project repository on GitHub: You should have a GitHub repository for the project you want to automate with GitHub Actions. If you don't have one, create a new repository or use an existing one.

  3. Basic understanding of GitHub Actions: While we'll guide you through the process, having a fundamental grasp of GitHub Actions will be beneficial. If you're new to GitHub Actions, you can check out GitHub's official documentation to get started.

Let's get to know step-by-step procedure:)

Step 1: Set up your GitHub repository and workflow

  • Create a new repository or use an existing one for this tutorial. Make sure your repository has the necessary files for your project.

  • Navigate to the "Actions" tab in your repository and click on "Set up a workflow yourself".

  • Give a name to your workflow file, such as "spheron-deployment.yml", and click "Edit new file".

Step 2: Configure the Spheron deployment workflow😤

Copy the following code and paste it into the new workflow file to configure the GitHub action to deploy your project with Spheron:

name: Deploy to Spheron

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v2

    - name: Set up Node.js
      uses: actions/setup-node@v2
      with:
        node-version: 14

    - name: Install dependencies
      run: npm ci

    - name: Build project
      run: npm run build

    - name: Deploy to Spheron
      uses: spheron/platform/action@v2
      with:
        username: ${{ secrets.SpheronUsername }}
        password: ${{ secrets.SpheronPassword }}
Enter fullscreen mode Exit fullscreen mode

Workflow

  • This configuration will trigger the action on every push to the main branch. It sets up Node.js, installs the dependencies, builds the project, and deploys it to Spheron.

Step 3: Add your Spheron credentials as "secrets"🤐

  • Navigate to the repository settings, and then click on "Secrets".

  • Add two new secrets named SpheronUsername and SpheronPassword with your Spheron username and password, respectively.

Step 4: Push your changes to GitHub

  • Commit the new workflow file to the main branch of your repository.

  • Once you push your changes, the GitHub Actions will trigger the deployment workflow, and you can view the progress in the "Actions" tab.

  • Upon successful completion, your project will be deployed to Spheron.

Conclusion🚀

In this tutorial, you’ve learned how to leverage Spheron's GitHub Actions to automate the deployment of your projects seamlessly. With this powerful feature, you can create efficient workflows for your development process and ensure that the latest changes are always deployed without manual intervention. Happy coding!😄

Follow me on twitter

Top comments (0)