Skip to content

Commit

Permalink
fix: replace 'vars' by 'secrets'
Browse files Browse the repository at this point in the history
  • Loading branch information
zong-zhe committed Sep 4, 2023
1 parent 8df9b34 commit 35b0b40
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 27 deletions.
18 changes: 5 additions & 13 deletions docs/push_by_github_action-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

```
21 changes: 7 additions & 14 deletions docs/push_by_github_action.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

```

0 comments on commit 35b0b40

Please sign in to comment.