# screeps-deploy-action

## Introduction

This GitHub Action facilitates the uploading of code to a Screeps server.
It's designed to automate the process of deploying JavaScript code to your Screeps account, ensuring that your game logic is consistently and efficiently updated.
Prerequisites

    A Screeps account with an access token.
    A GitHub or Gitea repository with your Screeps code.

## Usage

To use this action, you need to set it up in your workflow .yml file located in the .github/workflows directory of your repository.

## Inputs

- `protocol`: The protocol to use (default: https).
- `hostname`: The hostname of the Screeps server (default: screeps.com).
- `port`: The port to use (default: 443).
- `path`: The path for the API (default: /).
- `token`: Authentication token for Screeps.
- `username`: Username for Screeps account (used if no token is provided).
- `password`: Password for Screeps account (used if no token is provided).
- `prefix`: Directory prefix for file paths.
- `pattern`: Glob pattern to match files (default: *.js).
- `branch`: Branch in Screeps to which the code will be uploaded (default: default).
- `git-replace`: Overwrite "{{gitRef}}", "{{gitHash}}" and "{{deployTime}}" values in files matching the pattern.

Example Workflow

Create a `.yml` file (e.g., `screeps-deploy.yml`) in your repository's `.github/workflows` directory or `.gitea/workflows` directory:

```yaml
name: Deploy to Screeps

on: [push]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - name: Upload to Screeps
      uses: Screeps/screeps-deploy-action@main
      with:
        token: ${{ secrets.SCREEPS_TOKEN }}
        pattern: '**/*.js'
        branch: 'default'
        git-replace: /some_options.js
```

In this example:

- The action runs on every push to the repository.
- It checks out your code.
- Then, it uses the "Upload to Screeps" action to deploy the code to your Screeps account.
- You need to set SCREEPS_TOKEN in your repository secrets.

## Advanced Usage

Please note that you can easily filter your deployment branches in the push action.
Multiple deploy steps or jobs are recomended for mulitple deployments.