Exemplo n.º 1
0
        public XStaticResult Deploy(string folderPath)
        {
            try
            {
                if (!Repository.IsValid(folderPath))
                {
                    CloneRepo(folderPath, _branch);
                }

                CommitAndPush(folderPath, _branch);
            }
            catch (Exception e)
            {
                return(XStaticResult.Error("Error deploying site using Git.", e));
            }

            return(XStaticResult.Success("Git branch committed and pushed to remote."));
        }
        public virtual XStaticResult Deploy(string siteId, string folderPath)
        {
            Deployment deployment;

            var hashes = GetHashes(siteId, folderPath);

            try
            {
                deployment = CheckNetlifyForRequiredChanges(siteId, folderPath, hashes);
            }
            catch (WebException we)
            {
                return(XStaticResult.Error("Error uploding file hashes to Netlify. The deployment was not completed.", we));
            }
            catch (Exception e)
            {
                return(XStaticResult.Error("Error parsing Netlify response. The deployment was not completed.", e));
            }

            var client = new WebClient();

            client.Headers.Add("Authorization", "Bearer " + _pat);

            foreach (var hash in deployment.required)
            {
                var toUpload = hashes.Where(e => e.Value == hash);
                foreach (var fileHashToUpload in toUpload)
                {
                    try
                    {
                        UploadFileToNetlify(fileHashToUpload, folderPath, client, deployment);
                    }
                    catch (WebException ex)
                    {
                        client.Dispose();
                        return(XStaticResult.Error($"Error uploding file {fileHashToUpload.Key} to Netlify. The deployment was not completed.", ex));
                    }
                }
            }

            client.Dispose();
            return(XStaticResult.Success("Site was successfully deployed to Netlify."));
        }
Exemplo n.º 3
0
        public virtual XStaticResult Deploy(string folderPath)
        {
            try
            {
                FtpClient client = new FtpClient(_hostname, _port, _username, _password);
                client.EncryptionMode         = FtpEncryptionMode.Auto;
                client.ValidateAnyCertificate = true;
                client.Connect();

                var remoteFolder = string.IsNullOrEmpty(_folder) ? "/" : _folder;

                client.UploadDirectory(folderPath, remoteFolder, FtpFolderSyncMode.Mirror);

                client.Dispose();
            }
            catch (Exception e)
            {
                return(XStaticResult.Error("Error deploying the site using FTP.", e));
            }

            return(XStaticResult.Success("Site deployed using FTP."));
        }