hendry
February 10, 2020, 3:49am
1
Hi there, I managed to get my ex-ikiwiki site on S3/Cloudfront via https://github.com/kaihendry/dabase.com/blob/master/.github/workflows/hugo.yml
I created an IAM user for AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY secret:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1460356082000",
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": [
"arn:aws:s3:::dabase.com",
"arn:aws:s3:::dabase.com/*"
]
}
]
}
And another inline policy of:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "cloudfront:CreateInvalidation",
"Resource": "*"
}
]
}
I do find it concerning that JS seems to required for the Github action and peaceiris/actions-hugo seems far from simple: https://github.com/peaceiris/actions-hugo
Is there a simpler way??
Jura
February 10, 2020, 5:38am
2
I don’t have experience with GitHub Actions. But I did use s3deploy with my S3/Cloudfront setup. That worked good and quick.
Hugo also has the built-in hugo deploy command, which can also upload to S3 and invalidate Cloudfront.
Both options are JS free and hugo deploy
is probably the easiest to setup since it’s already inside Hugo.
hendry
February 10, 2020, 7:14am
3
I run hugo deploy ; it’s just that there doesn’t appear to be an official Hugo Docker image hence I am using the very odd peaceiris/actions-hugo action.
That Action just downloads a Hugo binary. You can do that by yourself with wget
and tar
.
Or, we can create a Docker image for Hugo by ourself like this: peaceiris/hugo-extended-docker
hendry
February 11, 2020, 12:01am
5
I think I prefer the Docker approach, but how does that look upon a Github Action?
Is it runs-on: peaceiris/hugo:latest?
Not sure how actions/checkout@master et al works…
We can run a Docker container the same as a local machine. actions/checkout@v1 or v2 check out a HEAD commit of GitHub events. (push commits, push tags, and so on.)
hendry
February 13, 2020, 8:21am
7
name: Deploy Hugo site to S3/Cloudfront
on:
push:
branches:
- master
jobs:
build-deploy:
runs-on: ubuntu-18.04
container:
image: peaceiris/hugo:v0.64.1
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- uses: actions/checkout@v1
- run: hugo --minify
- run: hugo deploy
I do not know the details of container:
syntax…
It works on my repo: https://github.com/peaceiris/peaceiris.github.io/actions/runs/38631898/workflow
It took 15 sec to initialize the container, the container option is slower than using peaceiris/actions-hugo
…
If you require the Hugo modules, you can use peaceiris/hugo:v0.64.1-mod
.
hendry
February 13, 2020, 12:43pm
10
Thank you, Got it working here:
https://github.com/kaihendry/dabase.com/actions … it appears as fast as before ~30s.
Must say I find it weird that I need to specify the container image Ubuntu in order to run your image in the lines:
runs-on: ubuntu-latest
container:
image: peaceiris/hugo
1 Like
bep
February 13, 2020, 12:49pm
11
I misread your domain name as database.com
and thought oh my, that looks like a lucrative domain name…