Skip to content

Commit

Permalink
Move pipelines to end of readme
Browse files Browse the repository at this point in the history
  • Loading branch information
markwylde committed May 10, 2023
1 parent 6026d11 commit 5395ec0
Showing 1 changed file with 87 additions and 87 deletions.
174 changes: 87 additions & 87 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ DeploySteps is a simple and flexible ISaaC library that allows you to automate v

- [Concept](#concept)
- [Installation](#installation)
- [Pipelines](#pipelines)
- [Usage](#usage)
- [Users Configuration](#users-configuration)
- [Servers Configuration](#servers-configuration)
Expand All @@ -17,6 +16,7 @@ DeploySteps is a simple and flexible ISaaC library that allows you to automate v
- [syncUsers](#syncusers)
- [enforceSshPublicKeyOnly](#enforcesshpublickeyonly)
- [copy](#copy)
- [Pipelines](#pipelines)

## Concept

Expand All @@ -30,92 +30,6 @@ Install DeploySteps by running the following command in your project directory:
npm install --save @deploysteps/core
```

## Pipelines

The point of DeploySteps, and ISaaC in general, is to commit your infrastructure scripts into a git repo, and have actions trigger through the CI/CD pipelines.

GitHub Actions provide a powerful and flexible way to automate your deployment workflows. By integrating DeploySteps with GitHub Actions, you can automatically execute your server management tasks whenever changes are pushed to your repository.

To deploy your servers using DeploySteps and GitHub Actions, follow the steps below:

### 1. Create a GitHub Actions Workflow

In your repository, create a new directory called `.github/workflows`, if it doesn't already exist. Inside this directory, create a new file called `deploy.yml`. This file will contain the configuration for your GitHub Actions deployment workflow.

### 2. Configure the Workflow

Add the following YAML configuration to your `deploy.yml` file:

```yaml
name: Deploy

on:
schedule:
# Runs "At 22:00 on every day-of-week from Monday through Friday."
- cron: '0 22 * * 1-5'
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest

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

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

- name: Install dependencies
run: npm ci

- name: Deploy to servers
run: node sync.js
env:
PRIVATE_KEY: ${{ secrets.SERVER_PRIVATE_KEY }}
USER1_PUBLIC_KEY: ${{ secrets.USER1_PUBLIC_KEY }}
```
This configuration sets up a workflow that triggers whenever you push changes to the `main` branch. It checks out your repository, sets up Node.js, installs your dependencies, and runs your `sync.js` script.

### 3. Configure Secrets

Sensitive information, such as private keys and public keys, should not be stored directly in your repository. Instead, you should use [GitHub Secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets) to securely store this information.

In your GitHub repository, navigate to the **Settings** tab, and then click on **Secrets**. Add the following secrets:

- `SERVER_PRIVATE_KEY`: The private SSH key used to connect to your server.
- `USER1_PUBLIC_KEY`: The public SSH key for the user you want to manage on the server.

### 4. Create the `sync.js` Script

In your `sync.js` script, replace the file reading operations for private and public keys with the corresponding environment variables provided by GitHub Actions:

```javascript
const servers = [
{
host: '192.168.1.100',
port: 22,
username: 'myAccount',
password: 'Password@12345',
privateKey: process.env.SERVER_PRIVATE_KEY,
tasks: [
updateDebian()
]
}
];
```

### 5. Push Your Changes

Commit and push your changes to the `main` branch. GitHub Actions will now automatically execute your deployment workflow whenever you push changes to your repository.

With this setup, you can leverage the power of GitHub Actions and DeploySteps to automate your server management tasks, ensuring your servers stay up-to-date and secure with every push.

## Usage

To use DeploySteps, you'll need to create a script that defines a set of servers and task you want to run.
Expand Down Expand Up @@ -331,3 +245,89 @@ export const installVim = () => ({
}
});
```

## Pipelines

The point of DeploySteps, and ISaaC in general, is to commit your infrastructure scripts into a git repo, and have actions trigger through the CI/CD pipelines.

GitHub Actions provide a powerful and flexible way to automate your deployment workflows. By integrating DeploySteps with GitHub Actions, you can automatically execute your server management tasks whenever changes are pushed to your repository.

To deploy your servers using DeploySteps and GitHub Actions, follow the steps below:

### 1. Create a GitHub Actions Workflow

In your repository, create a new directory called `.github/workflows`, if it doesn't already exist. Inside this directory, create a new file called `deploy.yml`. This file will contain the configuration for your GitHub Actions deployment workflow.

### 2. Configure the Workflow

Add the following YAML configuration to your `deploy.yml` file:

```yaml
name: Deploy

on:
schedule:
# Runs "At 22:00 on every day-of-week from Monday through Friday."
- cron: '0 22 * * 1-5'
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest

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

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

- name: Install dependencies
run: npm ci

- name: Deploy to servers
run: node sync.js
env:
PRIVATE_KEY: ${{ secrets.SERVER_PRIVATE_KEY }}
USER1_PUBLIC_KEY: ${{ secrets.USER1_PUBLIC_KEY }}
```
This configuration sets up a workflow that triggers whenever you push changes to the `main` branch. It checks out your repository, sets up Node.js, installs your dependencies, and runs your `sync.js` script.

### 3. Configure Secrets

Sensitive information, such as private keys and public keys, should not be stored directly in your repository. Instead, you should use [GitHub Secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets) to securely store this information.

In your GitHub repository, navigate to the **Settings** tab, and then click on **Secrets**. Add the following secrets:

- `SERVER_PRIVATE_KEY`: The private SSH key used to connect to your server.
- `USER1_PUBLIC_KEY`: The public SSH key for the user you want to manage on the server.

### 4. Create the `sync.js` Script

In your `sync.js` script, replace the file reading operations for private and public keys with the corresponding environment variables provided by GitHub Actions:

```javascript
const servers = [
{
host: '192.168.1.100',
port: 22,
username: 'myAccount',
password: 'Password@12345',
privateKey: process.env.SERVER_PRIVATE_KEY,
tasks: [
updateDebian()
]
}
];
```

### 5. Push Your Changes

Commit and push your changes to the `main` branch. GitHub Actions will now automatically execute your deployment workflow whenever you push changes to your repository.

With this setup, you can leverage the power of GitHub Actions and DeploySteps to automate your server management tasks, ensuring your servers stay up-to-date and secure with every push.

0 comments on commit 5395ec0

Please sign in to comment.