What happens when I link my account to github?



  • I currently have my IDE updating local files on /default, also linked that project to a github repository, so right now when I update files on local it updates on screeps. then I can optionally push code to github, create branches and stuff.

     

    Now what happens if I link my screeps account to github? does the game keep updating from local files as well? it would update from local files when saving changes and from github when push/commit? that's really weird and may lead to some sync issues since what I see on my IDE may not be the latest version.

     

    If both methods keep working together in that messy way, should I move my local files somehwere else and only updating when push/commiting or just stick to what I currently have, updates on local files are send to the game server and github serves as repo/backup? or maybe using both at the same time is best?

     

    Any idea?



  • I don't have the Steam version but what I do is use grunt to upload my scripts whenever I save in my IDE. To keep things versioned and available to those seeking inspiration I also push to github. If you want to have Screeps pull code from GitHub you could have your working directory somewhere else than your screeps directory.

    Screeps won't pull any code before you link your repo. 



  • I see, thanks for the info mate.



  • Once you link your github account/repository any time you update your repository those changes will get pulled into the screeps server. I set it up then started using grunt for pushing my changes because it was less steps that committing small changes constantly to git.

    In my experience the changes from git only get pulled into the game when you make a commit. So, if you make a bunch of changes locally and push them into the game those scripts will not be overwritten periodically by the contents of your git repo. BUT if you commit to your git repo (I believe only master branch, but I have not checked others) your committed changes would overwrite your current scripts.

    I think this works out rather well actually. Personally it allows me to work with scripts locally and then once I am happy with my changes push those changes into my repo. 



  • #Necroing for the sake of clarity, as that is one of the top google results when searching for GitHub integration info, but it lacked some details.

    1. GitHub Repo -> Screeps Server sync is one-directional only and occurs on new commits to GitHub Repo master branch.
      1. During that sync only files from Directory indicated in the repo sync config will be copied to the Server into your default "branch". No subdirectories. Remember to have that default branch selected as the running one.
    1. Editing code via Screeps WebApp changes files on the Server
      1. There is no sync back to the repo
      2. Webapp has no access to your local codebase, that is managed by Local Client, see below.
    1. As long as Local Screeps Client is running (also upon launch), it performs a two-directional auto-sync between Server and Local codebases. Every change is copied to the other environment, overwriting any unsaved changes there.
      1. This includes copying changes pulled into the Screeps Server from GitHub Repo (point 1 above).

      2. If you happen to have made changes both to local codebase while the Local Screeps Client was NOT running, and you also made changes on the Screeps Server, then upon launching the Local Screeps Client the conflict will be detected and you will see a warning:

        "Your remote scripts have been changed. Do you want to replace scripts on your local file system with the remote scripts? Your local changes will be LOST!"

        As indicated, that sync will be one-directional from Screeps Server to Local Screeps Client codebase and it is the only one destructive for your local saved changes, but you are getting a warning, so you can avoid that loss.

    So if you create a repo that will include the local codebase maintained by the Local Screeps Client, perhaps in: C:\Users\UserName\AppData\Local\Screeps\scripts\ (for Win10), and you publish that repo to GitHub, then you connect that repo in Account Management, and indicate a directory screeps.com/default, then you will essentially be able to have a workflow as follows:

    1. You can edit local codebase in the Local Screeps Client or your IDE of choice. No difference.
    2. That code is tracked in your repo, so you can commit/push that at any time.
    3. If the Local Screeps Client is running, you will get your code auto-synced to the Server. - this is preferred mode, as you can see the impact of your changes live.
    4. Regardless whether your Local Screeps Client is running, your code will be always synced to the Server upon git push to master branch (or merging of a pull request, if you're doing that in this repo).
    5. Committing and pushing code that is already synced up by the Local Client will not create a conflict, as Server will find no changes between what it already has from the Client and what it gets from the repo.
    6. If you, let's say, were on the go, away from your repo, and wanted to correct something via the Screeps WebApp, the only thing you need to do to sync those changes back to your Local Codebase and the local repo is launch your Local Screeps Client.

    Above workflow works like a charm for me.

    👍