Sync-ProValScripts
Description
Used to synchronize a target ProVal repository with the public file server repo.
Requirements
- Must be run as an Administrator.
- PowerShell v5
- Must be run as the non-Core version of PowerShell
Usage
- If git is not installed, the script will exit with an error.
- Installs/Imports the posh-git module.
- If an
ed25519
key is not found with the name specified in$SSHKeyName
, it will be generated.- The public key will be displayed in the console. Use this to add a new Deploy Key to the repo defined in
$RepoAlias
.
- The public key will be displayed in the console. Use this to add a new Deploy Key to the repo defined in
- The SSH fingerprints for GitHub will be added to the
known_hosts
for SSH, if missing. - A
Host
entry will be added to theconfig
file for SSH to use theed25519
key, if missing. - If the
$RepoAlias
repo has not been cloned, it will be cloned. - A
git fetch
is run against the repo. - A
git rev-parse
command is used to compare the commit at theHEAD
of the local repo versus theHEAD
of the origin.- If there are new commits to the origin, a
git pull
is run, and the functionMerge-GitWithLocal
is executed, ensuring that all changed files from GitHub are synced to$Path
. - If there are no new commits but
-Force
is specified, then the functionMerge-GitWithLocal
is still called. - Otherwise, the script exits with a message that the local repo is up to date with the origin.
- If there are new commits to the origin, a
Sets up the environment if required and syncs any new or changed scripts from the repo to the file server.
.\\Sync-ProValScripts.ps1
Sets up the environment if required and syncs any new or changed scripts from the repo to the file server, even if there are no new files in GitHub.
.\\Sync-ProValScripts.ps1 -Force
Parameters
Parameter | Required | Default | Type | Description |
---|---|---|---|---|
Path | False | 'E:\\repo\\script' | String | The path of the destination directory for the file server script repo. |
SSHKeyName | False | 'pvlscripts' | String | The name to give the generated SSH key pair. |
RepoAlias | False | 'scripts' | String | The name of the repo to sync from. |
GitHubEmail | False | 'support@provaltech.com' | String | The email address to use for the SSH key generation. |
ScriptTypes | False | ('.ps1', '.bat', '.py') | String[] | List of extensions that should be synced. |
Force | False | Switch | Use this switch to force a local diff check between the GitHub repo and the file server repo, even if the origin GitHub repo has no pending changes. |