deploy to deployment

This commit is contained in:
qiaofeng1227 2023-09-18 17:44:28 +08:00
parent de55f8c480
commit 491baead03
3 changed files with 28 additions and 8 deletions

View file

@ -4,7 +4,7 @@ on:
push:
branches: [main]
paths:
- "docker/w9deploy/Dockerfile"
- "docker/w9deployment/Dockerfile"
jobs:
build:
@ -18,7 +18,7 @@ jobs:
- name: Get version
run: |
version=$(grep -Po '(?<=LABEL version=").*?(?=")' docker/w9deploy/Dockerfile)
version=$(grep -Po '(?<=LABEL version=").*?(?=")' docker/w9deployment/Dockerfile)
echo $version
echo "::set-output name=version::$version"
echo "VERSION=$version" >> $GITHUB_ENV
@ -26,11 +26,11 @@ jobs:
- uses: mr-smithers-excellent/docker-build-push@v5
name: Build & push Docker image
with:
image: websoft9dev/deploy
image: websoft9dev/deployment
tags: ${{ env.VERSION }}
addLatest: True
registry: docker.io
dockerfile: docker/w9deploy/Dockerfile
directory: docker/w9deploy
dockerfile: docker/w9deployment/Dockerfile
directory: docker/w9deployment
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

View file

@ -9,4 +9,5 @@ RUN chmod +x /init_portainer
FROM portainer/portainer-ce:2.19.0
LABEL maintainer="websoft9<help@websoft9.com>"
LABEL version="2.19.0"
COPY --from=builder /init_portainer /

View file

@ -41,7 +41,7 @@ func main() {
}
}
content, err := ioutil.ReadFile(filePath)
content, err := readPasswordFromFile(filePath)
if err != nil {
fmt.Println("read file error:", err)
return
@ -74,7 +74,26 @@ func generatePassword(length int) string {
return string(password)
}
func writeToFile(filePath , content string) error {
func readPasswordFromFile(filePath string) (string, error) {
data, err := ioutil.ReadFile(filePath)
if err != nil {
return "", err
}
var passwordMap map[string]string
err = json.Unmarshal(data, &passwordMap)
if err != nil {
return "", err
}
password := passwordMap["password"]
return password, nil
}
return ioutil.WriteFile(filePath , []byte(content), 0755)
func writeToFile(filePath, password string) error {
data := map[string]string{"username": "admin", "password": password}
jsonData, err := json.Marshal(data)
if err != nil {
return err
}
err = ioutil.WriteFile(filePath, jsonData, 0755)
return err
}