Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] add workflow for auto deploy project #25

Closed
zhicheng-ning opened this issue Mar 18, 2023 · 1 comment · Fixed by #29
Closed

[feature] add workflow for auto deploy project #25

zhicheng-ning opened this issue Mar 18, 2023 · 1 comment · Fixed by #29
Assignees

Comments

@zhicheng-ning
Copy link
Member

  • 添加 CI/CD
  • 如何将私密 yaml 配置文件中的内容传入 workflow
@zhicheng-ning
Copy link
Member Author

要点:

    1. 可以在 Dockerfile 中可以显示设置环境变量,也可以在 docker build 过程中通过 build args 将参数传递到 image 里,然后再将 ARG 设置为 ENV
    1. 推荐方式是在 Docker run 的过程中通过将 env 参数直接传递到启动的容器中
docker run -e MYSQL_URL=${{ secrets.MYSQL_URL }} -e MYSQL_USERNAME=${{ secrets.MYSQL_USERNAME }} -e MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }} -e REDIS_HOST=${{ secrets.REDIS_HOST }} -e REDIS_PORT=${{ secrets.REDIS_PORT }} -e REDIS_PASSWORD=${{ secrets.REDIS_PASSWORD }} -e NZC_TOKEN=${{ secrets.NZC_TOKEN }} -e TYN_TOKEN=${{ secrets.TYN_TOKEN }} -e ZZW_TOKEN=${{ secrets.ZZW_TOKEN }} -e XXY_TOKEN=${{ secrets.XXY_TOKEN }} -e LZH_TOKEN=${{ secrets.LZH_TOKEN }} -d -p  8081:8080 --restart=always --name=od-api ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
  • 需要注意的一个坑点:在设置 MYSQL_URL 的 Secret 时,需要添加引号。
    • 例如程序中的 MYSQL_URL 为 jdbc:mysql://localhost:3306/od_api?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
    • 那么在 GitHub Action 中的 Secret 中需要设置为 'jdbc:mysql://localhost:3306/od_api?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant