mirror of https://github.com/docker/docs.git
Add GitHub action to upload S3 website configuration
Signed-off-by: Stefan Scherer <stefan.scherer@docker.com>
This commit is contained in:
parent
523fe77111
commit
57dcafed31
|
@ -15,3 +15,5 @@ Dockerfile.archive
|
|||
docker-compose.yml
|
||||
Gemfile
|
||||
Gemfile.lock
|
||||
_website*.json
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Dockerfile
|
||||
action.yml
|
|
@ -0,0 +1,11 @@
|
|||
FROM golang:1.14
|
||||
|
||||
WORKDIR /src
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN go build -o /bin/action
|
||||
|
||||
ENTRYPOINT ["/bin/action"]
|
|
@ -0,0 +1,16 @@
|
|||
name: update website config
|
||||
description: update the S3 website configuration
|
||||
inputs:
|
||||
bucketName:
|
||||
description: Name of the S3 bucket
|
||||
required: true
|
||||
regionName:
|
||||
description: Name of the AWS region of the S3 bucket
|
||||
required: true
|
||||
websiteConfig:
|
||||
description: Name of the website config JSON file
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: docker
|
||||
image: Dockerfile
|
|
@ -0,0 +1,8 @@
|
|||
module github.com/docker/docker.github.io/upload-website-config
|
||||
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/aws/aws-sdk-go v1.29.24
|
||||
github.com/sethvargo/go-githubactions v0.1.1
|
||||
)
|
|
@ -0,0 +1,18 @@
|
|||
github.com/aws/aws-sdk-go v1.29.24 h1:KOnds/LwADMDBaALL4UB98ZR+TUR1A1mYmAYbdLixLA=
|
||||
github.com/aws/aws-sdk-go v1.29.24/go.mod h1:1KvfttTE3SPKMpo8g2c6jL3ZKfXtFvKscTgahTma5Xg=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/sethvargo/go-githubactions v0.1.1 h1:u75rV0C+AvNjEUE4maSN844/U5eiy9Rlc3ahOU4EAfE=
|
||||
github.com/sethvargo/go-githubactions v0.1.1/go.mod h1:ugCoIFQjs7HxIwwYiY7ty6H9T+7Z4ey481HxqA3VRKE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
@ -0,0 +1,70 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
|
||||
"github.com/sethvargo/go-githubactions"
|
||||
)
|
||||
|
||||
// Upload a bucket's website configuration.
|
||||
func main() {
|
||||
bucketName := githubactions.GetInput("bucketName")
|
||||
if bucketName == "" {
|
||||
githubactions.Fatalf("missing input 'bucketName'")
|
||||
}
|
||||
|
||||
regionName := githubactions.GetInput("regionName")
|
||||
if regionName == "" {
|
||||
githubactions.Fatalf("missing input 'regionName'")
|
||||
}
|
||||
|
||||
websiteConfig := githubactions.GetInput("websiteConfig")
|
||||
if websiteConfig == "" {
|
||||
githubactions.Fatalf("missing input 'websiteConfig'")
|
||||
}
|
||||
|
||||
file, err := ioutil.ReadFile(websiteConfig)
|
||||
if err != nil {
|
||||
exitErrorf("Error reading json file %s, %v", websiteConfig, err)
|
||||
}
|
||||
|
||||
data := s3.WebsiteConfiguration{}
|
||||
err = json.Unmarshal([]byte(file), &data)
|
||||
if err != nil {
|
||||
exitErrorf("Error parsing JSON from file %s, %v", websiteConfig, err)
|
||||
}
|
||||
|
||||
sess, err := session.NewSession(&aws.Config{
|
||||
Region: aws.String(regionName)},
|
||||
)
|
||||
|
||||
svc := s3.New(sess)
|
||||
|
||||
// Create SetBucketWebsite parameters based on the JSON file input
|
||||
params := s3.PutBucketWebsiteInput{
|
||||
Bucket: aws.String(bucketName),
|
||||
WebsiteConfiguration: &data,
|
||||
}
|
||||
|
||||
// Set the website configuration on the bucket. Replacing any existing
|
||||
// configuration.
|
||||
_, err = svc.PutBucketWebsite(¶ms)
|
||||
if err != nil {
|
||||
exitErrorf("Unable to set bucket %q website configuration, %v",
|
||||
bucketName, err)
|
||||
}
|
||||
|
||||
fmt.Printf("Successfully set bucket %q website configuration\n", bucketName)
|
||||
}
|
||||
|
||||
func exitErrorf(msg string, args ...interface{}) {
|
||||
fmt.Fprintf(os.Stderr, msg+"\n", args...)
|
||||
os.Exit(1)
|
||||
}
|
|
@ -24,6 +24,16 @@ jobs:
|
|||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
if: github.repository == 'docker/docker.github.io' && github.event_name == 'push'
|
||||
- name: update S3 website config
|
||||
uses: ./.github/actions/update-website-config
|
||||
with:
|
||||
bucketName: docs.docker.com-stage-us-east-1
|
||||
regionName: us-east-1
|
||||
websiteConfig: _website-config-docs-stage.json
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
if: github.repository == 'docker/docker.github.io' && github.event_name == 'push'
|
||||
- name: invalidate docs website cache
|
||||
run: aws --region us-east-1 lambda invoke --function-name arn:aws:lambda:us-east-1:710015040892:function:docs-stage-cache-invalidator response.json
|
||||
env:
|
||||
|
|
|
@ -24,6 +24,16 @@ jobs:
|
|||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
if: github.repository == 'docker/docker.github.io' && github.event_name == 'push'
|
||||
- name: update S3 website config
|
||||
uses: ./.github/actions/update-website-config
|
||||
with:
|
||||
bucketName: docs.docker.com-us-east-1
|
||||
regionName: us-east-1
|
||||
websiteConfig: _website-config-docs.json
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
if: github.repository == 'docker/docker.github.io' && github.event_name == 'push'
|
||||
- name: invalidate docs website cache
|
||||
run: aws --region us-east-1 lambda invoke --function-name arn:aws:lambda:us-east-1:710015040892:function:docs-cache-invalidator response.json
|
||||
env:
|
||||
|
|
|
@ -0,0 +1,180 @@
|
|||
{
|
||||
"ErrorDocument": {
|
||||
"Key": "404.html"
|
||||
},
|
||||
"IndexDocument": {
|
||||
"Suffix": "index.html"
|
||||
},
|
||||
"RedirectAllRequestsTo": null,
|
||||
"RoutingRules": [
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v1.4/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs-stage.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v1.5/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs-stage.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v1.6/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs-stage.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v1.7/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs-stage.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v1.8/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs-stage.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v1.9/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs-stage.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v1.10/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs-stage.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v1.11/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs-stage.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v1.12/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs-stage.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v1.13/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs-stage.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v17.03/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs-stage.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v17.09/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs-stage.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v17.12/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs-stage.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,180 @@
|
|||
{
|
||||
"ErrorDocument": {
|
||||
"Key": "404.html"
|
||||
},
|
||||
"IndexDocument": {
|
||||
"Suffix": "index.html"
|
||||
},
|
||||
"RedirectAllRequestsTo": null,
|
||||
"RoutingRules": [
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v1.4/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v1.5/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v1.6/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v1.7/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v1.8/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v1.9/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v1.10/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v1.11/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v1.12/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v1.13/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v17.03/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v17.09/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Condition": {
|
||||
"HttpErrorCodeReturnedEquals": null,
|
||||
"KeyPrefixEquals": "v17.12/"
|
||||
},
|
||||
"Redirect": {
|
||||
"HostName": "docs.docker.com",
|
||||
"HttpRedirectCode": null,
|
||||
"Protocol": "https",
|
||||
"ReplaceKeyPrefixWith": "",
|
||||
"ReplaceKeyWith": null
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue