-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.json
4 lines (1 loc) · 9.56 KB
/
index.json
1
2
3
4
[{"content":" Intro # Publish is an awesome static site generator created by John Sundell. This website is built with this tool.\nOne of the steps is to upload to the server all the file generated, the first approach I used was to upload all the files in the output folder, via FTP manually but, then I had an idea.\nDeploy # For deployment, I use the following code:\n.publish( withTheme: .nsstudent, deployedUsing: DeploymentMethod.gitHub(\u0026#34;NSStudent/NSStudent\u0026#34;), ... } This is the implementation of the github method:\n/// Deploy a website to a given GitHub repository. /// - parameter repository: The full name of the repository (including its username). /// - parameter useSSH: Whether an SSH connection should be used (preferred). static func gitHub(_ repository: String, useSSH: Bool = true) -\u0026gt; Self { let prefix = useSSH ? \u0026#34;git@github.com:\u0026#34; : \u0026#34;https://github.com/\u0026#34; return git(\u0026#34;\\(prefix)\\(repository).git\u0026#34;) } This method searches the repository with the name NSStudent/NSStudent. By default, the implementation tries to clone the repository via SSH with this code inside the git method.\nstatic func git(_ remote: String) -\u0026gt; Self { DeploymentMethod(name: \u0026#34;Git (\\(remote))\u0026#34;) { context in let folder = try context.createDeploymentFolder(withPrefix: \u0026#34;Git\u0026#34;) { folder in if !folder.containsSubfolder(named: \u0026#34;.git\u0026#34;) { try shellOut(to: .gitInit(), at: folder.path) try shellOut( to: \u0026#34;git remote add origin \\(remote)\u0026#34;, at: folder.path ) } try shellOut( to: \u0026#34;git remote set-url origin \\(remote)\u0026#34;, at: folder.path ) _ = try? shellOut( to: .gitPull(remote: \u0026#34;origin\u0026#34;, branch: \u0026#34;master\u0026#34;), at: folder.path ) try folder.empty() } let dateFormatter = DateFormatter() dateFormatter.dateFormat = \u0026#34;yyyy-MM-dd HH:mm\u0026#34; let dateString = dateFormatter.string(from: Date()) do { try shellOut( to: \u0026#34;\u0026#34;\u0026#34; git add . \u0026amp;\u0026amp; git commit -a -m \\\u0026#34;Publish deploy \\(dateString)\\\u0026#34; --allow-empty \u0026#34;\u0026#34;\u0026#34;, at: folder.path ) try shellOut( to: .gitPush(remote: \u0026#34;origin\u0026#34;, branch: \u0026#34;master\u0026#34;), at: folder.path ) } catch let error as ShellOutError { throw PublishingError(infoMessage: error.message) } catch { throw error } } } The magic happens when the context calls context.createDeploymentFolder function. This method creates a new folder with the name GitDeploy inside to a hidden folder .publish.\nRight now, all the codes are in your repository.\nTo create the action to upload the website in the server via FTP, you need to add the following main.yml file:\nname: Deploy website on: [push] jobs: FTP-Deploy-Action: name: FTP-Deploy-Action runs-on: ubuntu-latest steps: - uses: actions/checkout@master - name: FTP-Deploy-Action uses: SamKirkland/FTP-Deploy-Action@2.0.0 env: FTP_SERVER: ${{ secrets.FTP_NAME }} FTP_USERNAME: ${{ secrets.FTP_USER }} FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }} ARGS: --delete --exclude-glob=.git*/** --exclude-glob=.git** --delete-excluded This file use the FTP-Deploy-Action. It has three secrets variables secrets.FTP_NAME, secrets.FTP_USER, secrets.FTP_PASSWORD to not expose the real values. The ARGS parameter tries to remove all unused files and it prevents the upload off all the files inside the .git or .github folders.\nYou need to pull this change in the current GitDeploy repository. Right now, every time you use Publish deploy in the terminal and push a new version in this repository, the action uploads all the files to the FTP.\nI will try to write with new things about Publish and how I use them in this blog.\n","date":"10 noviembre 2024","externalUrl":null,"permalink":"/en/posts/1731268430539-deploy-with-github-actions/","section":"Posts","summary":"","title":"Deploy Publish blog with Github Actions","type":"posts"},{"content":"","date":"10 noviembre 2024","externalUrl":null,"permalink":"/en/tags/publish/","section":"Tags","summary":"","title":"Publish","type":"tags"},{"content":"","date":"11 noviembre 2020","externalUrl":null,"permalink":"/en/tags/basics/","section":"Tags","summary":"","title":"Basics","type":"tags"},{"content":"Structs create a default initializer when you implement one.\nSometimes you want to create another initializer to facilitate the code.\nThe problems appear when you try to introduce our initializer. the default constructor disappears. To avoid this problem, the best way is to include our initializer inside an extension.\nThis way, we\u0026rsquo;ll keep the two builders\nstruct Person { let name: String let birthday: Date } extension Person { init(name: String) { self.name = name self.birthday = Date() } } let person = Person(name: \u0026#34;NSStudent\u0026#34;, birthday: Date(timeIntervalSince1970: 426348250)) let baby = Person(name: \u0026#34;john\u0026#34;) ","date":"11 noviembre 2020","externalUrl":null,"permalink":"/en/posts/1731339196747-struct-inits/","section":"Posts","summary":"","title":"Create a custom struct initializer","type":"posts"},{"content":"","date":"11 noviembre 2020","externalUrl":null,"permalink":"/en/tags/struct/","section":"Tags","summary":"","title":"Struct","type":"tags"},{"content":"","date":"26 de julio de 2020","externalUrl":null,"permalink":"/tags/espa%C3%B1ol/","section":"Tags","summary":"","title":"Español","type":"tags"},{"content":"","date":"26 de julio de 2020","externalUrl":null,"permalink":"/","section":"NSStudent blog","summary":"","title":"NSStudent blog","type":"page"},{"content":"","date":"26 de julio de 2020","externalUrl":null,"permalink":"/posts/","section":"Posts","summary":"","title":"Posts","type":"posts"},{"content":"","date":"26 de julio de 2020","externalUrl":null,"permalink":"/tags/spm/","section":"Tags","summary":"","title":"Spm","type":"tags"},{"content":"","date":"26 de julio de 2020","externalUrl":null,"permalink":"/tags/swift/","section":"Tags","summary":"","title":"Swift","type":"tags"},{"content":"","date":"26 de julio de 2020","externalUrl":null,"permalink":"/tags/","section":"Tags","summary":"","title":"Tags","type":"tags"},{"content":"","date":"26 de julio de 2020","externalUrl":null,"permalink":"/tags/tips/","section":"Tags","summary":"","title":"Tips","type":"tags"},{"content":" Introducción # Normalmente, cuando desarrollamos, intentamos hacer nuestro código reutilizable. Muchas cosas que hacemos en nuestros proyectos son comunes, conectarte a una API, cachear las imágenes de la red, etc.\nPara poder manejar estos recursos normalmente hacemos uso de gestores de dependencias pero, para el desarrollo en iOS, no teníamos un gestor facilitado por Apple. Hasta hace bien poco la mayoría de los desarrolladores estábamos usando Cocoapods(poner link) o Carthage(poner link) para poder cubrir esta necesidad.\nCon Swift Package Manager (SPM) Apple intenta dar solución a esta demanda de los desarrolladores y en la última session de la WWDC han incluido cosas que hace a SPM un posible candidato para la gestión de dependencias en producción.\nMientras estás desarrollando tu dependencia una de las necesidades es poder modificar el código en tiempo de desarrollo dentro del proyecto. Apple no deja muy claro en su documentación como hacer esto, veamos paso por paso como poderlo hacer.\nEjemplo # El primer paso seria crear el package, para ello crea una carpeta en la ruta donde quieras hacer el ejemplo y dentro de esta carpeta ejecuta la inicialización del package.\nmkdir PackageExample cd PackageExample swift package init Para este tutorial vamos a crear el proyecto nuevo al que queremos incluir este package a la misma altura que la carpeta contenedora, esta seria la estructura de la carpeta actualmente.\nCarpeta Contenedora - ExampleProject - PackageExample El siguiente paso es arrastrar la carpeta del package en el proyecto\nUn detalle importante para que todo funcione es que no puedes tener abierto el package en el Xcode, de lo contrario no te mostrará la jerarquía de archivos al arrastrarlo.\nEl último paso que nos falta para que todo funcione es conectar la librería con el proyecto, esto se hace en la sección de Build Phases del proyecto en el apartado de Link Binary With Libraries, le damos al botón de + y seleccionamos la librería de nuestro package.\nCon esto ya podras hacer el import de tu package en el proyecto y modificar el código a tu gusto.\n","date":"26 de julio de 2020","externalUrl":null,"permalink":"/posts/1731267965610-trabajar-con-packages-en-local/","section":"Posts","summary":"","title":"Trabajar con Packages en local","type":"posts"},{"content":" Sobre mí # Hola a todos\nMi nombre es Omar, pero me conocen como NSStudent. Soy un desarrollador iOS de Madrid, España.\nCuando tengo tiempo, me gusta ir a los meetups de NSCoder para compartir conocimientos con todos los desarrolladores de Madrid. Una de las cosas que más me impresionó, cuando empecé como desarrollador iOS, fue el buen ambiente que había en la comunidad iOS.\nEsta es mi web personal, blog y laboratorio para probar todas las novedades de Swift.\nSi quieres hablar más conmigo, puedes contactar a través de Twitter\n¡Saludos!\n","externalUrl":null,"permalink":"/about/","section":"NSStudent blog","summary":"","title":"","type":"page"},{"content":"","externalUrl":null,"permalink":"/authors/","section":"Authors","summary":"","title":"Authors","type":"authors"},{"content":"","externalUrl":null,"permalink":"/categories/","section":"Categories","summary":"","title":"Categories","type":"categories"},{"content":"","externalUrl":null,"permalink":"/series/","section":"Series","summary":"","title":"Series","type":"series"}]