From 35b0b401f86892626d0774b1298d2e5d54651374 Mon Sep 17 00:00:00 2001 From: zongz Date: Mon, 4 Sep 2023 19:15:39 +0800 Subject: [PATCH] fix: replace 'vars' by 'secrets' --- docs/push_by_github_action-zh.md | 18 +++++------------- docs/push_by_github_action.md | 21 +++++++-------------- 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/docs/push_by_github_action-zh.md b/docs/push_by_github_action-zh.md index 433d4773..6b265416 100644 --- a/docs/push_by_github_action-zh.md +++ b/docs/push_by_github_action-zh.md @@ -37,18 +37,10 @@ ### 2. 为您的仓库设置 OCI Registry,账户和密码 -#### 2.1 通过 GitHub action variables 设置您的 OCI Registry,账户 - -[为 Github 仓库设置 Variables](https://docs.github.com/zh/actions/learn-github-actions/variables#creating-configuration-variables-for-a-repository) - -以 docker.io 为例,您可以为您的仓库设置两个 Variables `REG` 和 `REG_ACCOUNT`。`REG` 的值为 `docker.io`,`REG_ACCOUNT` 的值为您的 docker.io 账户。 - -#### 2.2 通过 GitHub action secrets 设置您的 OCI Registry 密码 +以 docker.io 为例,您可以为您的仓库设置 secrets `REG`, `REG_ACCOUNT` 和 `REG_TOKEN`。`REG` 的值为 `docker.io`,`REG_ACCOUNT` 的值为您的 docker.io 账户, `REG_TOKEN` 为您的 `docker.io` 登录密码。 [为仓库添加 secrets](https://docs.github.com/zh/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) -以 `docker.io` 为例,您可以将您的 `docker.io` 登录密码设置为名为 `REG_TOKEN` 的 secrets 。 - 如果您使用 `ghcr.io` 作为 `Registry`, 您需要使用 GitHub token 作为 secrets。 [创建一个 GitHub Token](https://docs.github.com/zh/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#personal-access-tokens-classic) @@ -84,12 +76,12 @@ jobs: - name: Login and Push env: # 通过环境变量指定 OCI Registry 和账户 - KPM_REG: ${{ vars.REG }} - KPM_REPO: ${{ vars.REG_ACCOUNT }} + KPM_REG: ${{ secrets.REG }} + KPM_REPO: ${{ secrets.REG_ACCOUNT }} # kpm login 时使用 secrets.REG_TOKEN - run: kpm login -u ${{ vars.REG_ACCOUNT }} -p ${{ secrets.REG_TOKEN }} ${{ vars.REG }} && kpm push + run: kpm login -u ${{ secrets.REG_ACCOUNT }} -p ${{ secrets.REG_TOKEN }} ${{ secrets.REG }} && kpm push - name: Run kpm project from oci registry - run: kpm run oci://${{ vars.REG }}/${{ vars.REG_ACCOUNT }}/catalog --tag 0.0.1 + run: kpm run oci://${{ secrets.REG }}/${{ secrets.REG_ACCOUNT }}/catalog --tag 0.0.1 ``` diff --git a/docs/push_by_github_action.md b/docs/push_by_github_action.md index c5ef9913..8830f627 100644 --- a/docs/push_by_github_action.md +++ b/docs/push_by_github_action.md @@ -35,20 +35,13 @@ In this repository, add your KCL program, take the repository https://github.com ### 2. Set OCI Registry, account and password for your Github repository -#### 2.1 Set OCI Registry and account through GitHub action variables +Take docker.io as an example, you can set secrets `REG`, `REG_ACCOUNT` and `REG_TOKEN` for your repository. The value of `REG` is `docker.io`, the value of `REG_ACCOUNT` is your `docker.io` account, and the value of `REG_TOKEN` is your `docker.io` login password. -[Set Variables for Github repository](https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-a-repository) - -Take `docker.io` as an example, you can set two Variables `REG` and `REG_ACCOUNT` for your repository. The value of `REG` is `docker.io`, and the value of `REG_ACCOUNT` is your docker.io account. - -#### 2.2 Set your OCI Registry password through GitHub action secrets -[Add secrets for repository](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) - -Take `docker.io` as an example, you can set your `docker.io` login password as a secrets named `REG_TOKEN`. +[Add secrets to the repository](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) If you use `ghcr.io` as `Registry`, you need to use GitHub token as secrets. -[Create a GitHub Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) +[Create a GitHub Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#personal-access-tokens-classic) ## Step 4: Add your KCL package to the repository and write github action workflow @@ -79,11 +72,11 @@ jobs: - name: Login and Push env: - KPM_REG: ${{ vars.REG }} - KPM_REPO: ${{ vars.REG_ACCOUNT }} - run: kpm login -u ${{ vars.REG_ACCOUNT }} -p ${{ secrets.REG_TOKEN }} ${{ vars.REG }} && kpm push + KPM_REG: ${{ secrets.REG }} + KPM_REPO: ${{ secrets.REG_ACCOUNT }} + run: kpm login -u ${{ secrets.REG_ACCOUNT }} -p ${{ secrets.REG_TOKEN }} ${{ secrets.REG }} && kpm push - name: Run kpm project from oci registry - run: kpm run oci://${{ vars.REG }}/${{ vars.REG_ACCOUNT }}/catalog --tag 0.0.1 + run: kpm run oci://${{ secrets.REG }}/${{ secrets.REG_ACCOUNT }}/catalog --tag 0.0.1 ```