Skip to content

Commit 6feb200

Browse files
committed
Add deploy step
1 parent 7ceda7f commit 6feb200

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Source for [bytesized.co](https://www.bytesized.co).
44
bytesized.co is statically generated using [Publish](https://github.com/JohnSundell/Publish), a static site generator written in Swift.
55

66
## Publishing to S3
7-
```
8-
swift run -c release
9-
aws s3 sync Output/. s3://<Bucket> --exclude "*.DS_Store*"
7+
```bash
8+
swift run -c release bytesized --deploy
109
```

Sources/bytesized/main.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Foundation
22
import Publish
33
import Plot
4+
import ShellOut
45

56
struct Bytesized: Website {
67
enum SectionID: String, WebsiteSectionID {
@@ -53,5 +54,16 @@ try Bytesized().publish(using: [
5354
}
5455
}
5556
},
56-
.generateHTML(withTheme: .bytesized, fileMode: .standAloneFiles)
57+
.generateHTML(withTheme: .bytesized, fileMode: .standAloneFiles),
58+
.deploy(using: .s3("bytesized.co"))
5759
])
60+
61+
public extension DeploymentMethod {
62+
// Requires AWS CLI to be installed
63+
static func s3(_ bucket: String) -> Self {
64+
DeploymentMethod(name: "S3 (\(bucket))") { context in
65+
let s3 = try context.createDeploymentFolder(withPrefix: "s3_", configure: { _ in })
66+
try shellOut(to: "aws s3 sync \(s3.path) s3://\(bucket) --exclude \"*.DS_Store*\"", outputHandle: FileHandle.standardOutput)
67+
}
68+
}
69+
}

0 commit comments

Comments
 (0)