1
0
Fork 0

Automatically update README

master
Ambrose Chua 2021-11-16 14:22:55 +08:00
parent 557186b6fb
commit 822c883b71
6 changed files with 73 additions and 14 deletions

View File

@ -32,8 +32,8 @@ jobs:
- name: Regenerate Dockerfiles
run: |
go run update.go -dockerfiles
go run update.go -dockerfiles -readme
- name: Commit and push changes
id: commit-dockerfiles
run: |

1
.gitignore vendored
View File

@ -1,2 +1 @@
caddy.go
go.sum

View File

@ -1,20 +1,19 @@
# [caddy](https://hub.docker.com/r/productionwentdown/caddy/) [![](https://images.microbadger.com/badges/version/productionwentdown/caddy.svg)](https://microbadger.com/images/productionwentdown/caddy "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/productionwentdown/caddy.svg)](https://microbadger.com/images/productionwentdown/caddy "Get your own image badge on microbadger.com")
# [caddy](https://hub.docker.com/r/productionwentdown/caddy/) ![Docker Pulls](https://img.shields.io/docker/pulls/productionwentdown/caddy) ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/productionwentdown/caddy/alpine?style=flat-square)
A tiny <10MB Caddy image compressed with [UPX](https://github.com/upx/upx).
# Shared Tags
New versions are tracked within 4 hours. As of the time of writing, these are the tags available:
New versions are tracked within 4 hours. Currently available versions:
* `2.3.0-alpine`, `2-alpine`, `alpine`
For the most up-to-date information, visit the Docker Hub tags page.
* `2.4.6-alpine`, `2-alpine`, `alpine`
Legacy tags available that should not be used:
* `2.0.0`
* `1.0.5`, `1`
* `1.0.0`, `1.0.1`, `1.0.2`, `1.0.3`, `1.0.4`, `1.0.5`, `1`
* `0.10.*`, `0.11.*`
# Usage

6
go.mod
View File

@ -1,8 +1,8 @@
module github.com/productionwentdown/caddy
go 1.14
go 1.16
require (
github.com/docker-library/go-dockerlibrary v0.0.0-20200501195759-c5db18cf68eb
pault.ag/go/debian v0.0.0-20190530135403-b831f604d664 // indirect
github.com/docker-library/go-dockerlibrary v0.0.0-20200821205225-669fbe5c1d52
pault.ag/go/debian v0.12.0 // indirect
)

16
go.sum Normal file
View File

@ -0,0 +1,16 @@
github.com/DataDog/zstd v1.4.8/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
github.com/docker-library/go-dockerlibrary v0.0.0-20200821205225-669fbe5c1d52 h1:Z3GnSICOyARBY/IBnOWtNN8N4AVRRDWxPEH28AM8wsg=
github.com/docker-library/go-dockerlibrary v0.0.0-20200821205225-669fbe5c1d52/go.mod h1:ijRhN3WM71dD8TfohKoUdX46BT2uz/Ek5O+5PINI880=
github.com/kjk/lzma v0.0.0-20161016003348-3fd93898850d/go.mod h1:phT/jsRPBAEqjAibu1BurrabCBNTYiVI+zbmyCZJY6Q=
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E=
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
pault.ag/go/debian v0.12.0 h1:b8ctSdBSGJ98NE1VLn06aSx70EUpczlP2qqSHEiYYJA=
pault.ag/go/debian v0.12.0/go.mod h1:UbnMr3z/KZepjq7VzbYgBEfz8j4+Pyrm2L5X1fzhy/k=
pault.ag/go/topsort v0.0.0-20160530003732-f98d2ad46e1a h1:WwS7vlB5H2AtwKj1jsGwp2ZLud1x6WXRXh2fXsRqrcA=
pault.ag/go/topsort v0.0.0-20160530003732-f98d2ad46e1a/go.mod h1:INqx0ClF7kmPAMk2zVTX8DRnhZ/yaA/Mg52g8KFKE7k=

View File

@ -1,9 +1,9 @@
package main
import (
"os"
"flag"
"io/ioutil"
"os"
"path"
"strings"
"text/template"
@ -16,6 +16,28 @@ var manifestURL = "https://github.com/docker-library/official-images/raw/master/
var maintainers = []string{"Ambrose Chua <ambrose@makerforce.io> (@serverwentdown)"}
var gitRepo = "https://github.com/productionwentdown/caddy.git"
var readmeTemplate = template.Must(template.New("readme").Parse(`
# [caddy](https://hub.docker.com/r/productionwentdown/caddy/) ![Docker Pulls](https://img.shields.io/docker/pulls/productionwentdown/caddy) ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/productionwentdown/caddy/alpine?style=flat-square)
A tiny &lt;10MB Caddy image compressed with [UPX](https://github.com/upx/upx).
# Shared Tags
New versions are tracked within 4 hours. Currently available versions:
{{range $entry := .Entries}}
* {{range $index, $tag := $entry.Tags}}{{if $index}}, {{end}}` + "`{{$tag}}`" + `{{end}}
{{end}}
Legacy tags available that should not be used:
* ` + "`2.0.0`" + `
* ` + "`1.0.0`, `1.0.1`, `1.0.2`, `1.0.3`, `1.0.4`, `1.0.5`, `1`" + `
* ` + "`0.10.*`, `0.11.*`" + `
# Usage
See the [official image](https://hub.docker.com/_/caddy) for documentation. This image behaves the same way, except that it is much slimmer.
`))
var dockerfileTemplate = template.Must(template.New("name").Parse(`FROM caddy:{{.Tag}} as build
RUN apk add --no-cache upx ca-certificates \
@ -58,12 +80,13 @@ CMD ["/usr/bin/caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "
type dockerfileData struct {
Tag string
Version string
Arch string
Arch string
}
func main() {
doDockerfiles := flag.Bool("dockerfiles", false, "Update Dockerfiles")
doManifest := flag.Bool("manifest", false, "Update manifest")
doReadme := flag.Bool("readme", false, "Update README.md")
commit := flag.String("commit", "", "Current commit hash")
flag.Parse()
@ -86,6 +109,12 @@ func main() {
panic(err)
}
}
if *doReadme {
err = updateReadme(man)
if err != nil {
panic(err)
}
}
}
// subsetManifest returns the subset of the manifest that can be built
@ -171,3 +200,19 @@ func updateManifest(man *manifest.Manifest2822, gitCommit string) error {
}
return ioutil.WriteFile(manifestPath, []byte(man.String()), 0644)
}
// updateReadme generates a new README.md
func updateReadme(man *manifest.Manifest2822) error {
readmeFile, err := os.OpenFile("README.md", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
if err != nil {
return err
}
defer readmeFile.Close()
err = readmeTemplate.Execute(readmeFile, man)
if err != nil {
return err
}
return nil
}