mirror of
https://github.com/Websoft9/websoft9.git
synced 2025-01-24 18:30:23 +08:00
deploy to deployment
This commit is contained in:
parent
de55f8c480
commit
491baead03
@ -4,7 +4,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
paths:
|
paths:
|
||||||
- "docker/w9deploy/Dockerfile"
|
- "docker/w9deployment/Dockerfile"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@ -18,7 +18,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Get version
|
- name: Get version
|
||||||
run: |
|
run: |
|
||||||
version=$(grep -Po '(?<=LABEL version=").*?(?=")' docker/w9deploy/Dockerfile)
|
version=$(grep -Po '(?<=LABEL version=").*?(?=")' docker/w9deployment/Dockerfile)
|
||||||
echo $version
|
echo $version
|
||||||
echo "::set-output name=version::$version"
|
echo "::set-output name=version::$version"
|
||||||
echo "VERSION=$version" >> $GITHUB_ENV
|
echo "VERSION=$version" >> $GITHUB_ENV
|
||||||
@ -26,11 +26,11 @@ jobs:
|
|||||||
- uses: mr-smithers-excellent/docker-build-push@v5
|
- uses: mr-smithers-excellent/docker-build-push@v5
|
||||||
name: Build & push Docker image
|
name: Build & push Docker image
|
||||||
with:
|
with:
|
||||||
image: websoft9dev/deploy
|
image: websoft9dev/deployment
|
||||||
tags: ${{ env.VERSION }}
|
tags: ${{ env.VERSION }}
|
||||||
addLatest: True
|
addLatest: True
|
||||||
registry: docker.io
|
registry: docker.io
|
||||||
dockerfile: docker/w9deploy/Dockerfile
|
dockerfile: docker/w9deployment/Dockerfile
|
||||||
directory: docker/w9deploy
|
directory: docker/w9deployment
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
@ -9,4 +9,5 @@ RUN chmod +x /init_portainer
|
|||||||
FROM portainer/portainer-ce:2.19.0
|
FROM portainer/portainer-ce:2.19.0
|
||||||
LABEL maintainer="websoft9<help@websoft9.com>"
|
LABEL maintainer="websoft9<help@websoft9.com>"
|
||||||
LABEL version="2.19.0"
|
LABEL version="2.19.0"
|
||||||
|
|
||||||
COPY --from=builder /init_portainer /
|
COPY --from=builder /init_portainer /
|
@ -41,7 +41,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
content, err := ioutil.ReadFile(filePath)
|
content, err := readPasswordFromFile(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("read file error:", err)
|
fmt.Println("read file error:", err)
|
||||||
return
|
return
|
||||||
@ -74,7 +74,26 @@ func generatePassword(length int) string {
|
|||||||
return string(password)
|
return string(password)
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeToFile(filePath , content string) error {
|
func readPasswordFromFile(filePath string) (string, error) {
|
||||||
|
data, err := ioutil.ReadFile(filePath)
|
||||||
return ioutil.WriteFile(filePath , []byte(content), 0755)
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user