feat: support publish_server_image to dockerhub automatically (V2)#1
feat: support publish_server_image to dockerhub automatically (V2)#1imbajin merged 15 commits intohugegraph:masterfrom
Conversation
|
|
|
@Radeity could also take a look for it when free, THX |
|
|
||
| - name: Get current commit-hash | ||
| run: | | ||
| current_commit_hash=$(git rev-parse HEAD) |
There was a problem hiding this comment.
TODO: seems current_commit VS last_commit is enough
rename to current_commit (remove hash suffix)
There was a problem hiding this comment.
I want to keep the style same as the one in name "Get current commit-hash"
There was a problem hiding this comment.
I want to keep the style same as the one in name "Get current commit-hash"
fine, u could update the title style or not
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max |
There was a problem hiding this comment.
TODO: check if the docker image cache work well (seems doesn't take effect now?)
could fix it in next/another PR, just address it
Co-authored-by: imbajin <[email protected]>
Co-authored-by: imbajin <[email protected]>
Co-authored-by: imbajin <[email protected]>
| env: | ||
| repository_url: apache/hugegraph | ||
| branch: master | ||
| image_url: hugegraph/hugegraph:latest |
There was a problem hiding this comment.
refer server CI file, maybe we could:
- use the
env.xxdirectly? like
2. put all params here (to keep the logic clean)
and search/ask GPT for the difference between $param & ${{env.param}} in action (seems $param looks better)
There was a problem hiding this comment.
- The difference is mentioned in https://hugegraph.feishu.cn/docx/U8LKdSsxWoyxlnxKSXPcNoOanJd#HpV9dR7UfoCbyOxsxwNcRucHnCf

- I do not find a way to use regexp when setting the env, same with gpt

| repository: ${{ env.REPOSITORY_URL }} | ||
| ref: ${{ env.BRANCH }} |
There was a problem hiding this comment.
what's the difference between ${{ env.BRANCH }} & $BRANCH? how to choose
There was a problem hiding this comment.
They do not have real difference, but in Github action docs, it said that:
"Runner environment variables are always interpolated on the runner machine. However, parts of a workflow are processed by GitHub Actions and are not sent to the runner. You cannot use environment variables in these parts of a workflow file. Instead, you can use contexts. For example, an if conditional, which determines whether a job or step is sent to the runner, is always processed by GitHub Actions. You can use a context in an if conditional statement to access the value of an variable."
It mease that we can not directly use $BRANCH in these parts like "if" or "with", and we must use env context to get them. Because they are processed by github action, but not runner machine. You can not use $BRANCH to get the value. In github action, there is not $BRANCH, but only the env context or other context.
But in "run statement", these vars are sent to runner machine instead of github action, where we can use $BRANCH directly to get the value.
BTW, in "if conditional statement", use ${{ }} seems to be the recommended way, I have fixed it.
| -d '{"name":"'"$var_name"'","value":"'"$current_commit_hash"'"}' | ||
| -H "Authorization: Bearer $GITHUB_TOKEN" \ | ||
| https://api.github.com/repos/$OWNER/$REPO/actions/variables/LAST_COMMIT_HASH \ | ||
| -d '{"name":"LAST_COMMIT_HASH","value":"'"$CURRENT_COMMIT_HASH"'"}' No newline at end of file |
There was a problem hiding this comment.
I develop on remote server with vsc remote-ssh plugin, and there is no copy on my local machine. Github desktop can not deal with the case.
Is there any recommended plugin to check problem like these?
There was a problem hiding this comment.
I develop on remote server with vsc remote-ssh plugin, and there is no copy on my local machine. Github desktop can not deal with the case. Is there any recommended plugin to check problem like these?
check it manually after u push the commit:)
This comment was marked as resolved.
This comment was marked as resolved.
I can not see the pending msg. And in this reply, this image.png is also invisible. |
| steps: | ||
| - name: Set branch | ||
| run: | | ||
| branch=${{ inputs.branch=='' && env.branch || inputs.branch }} |
There was a problem hiding this comment.
We can choose specific branch instead of release-{tag} as the branch.
Generally, we only need to provide the tag, then the branch will be set to "release-{tag}"
|
|
||
| - name: Updata last SHA | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.PAT }} |
There was a problem hiding this comment.
Yes, "PAT" is a token accessible to the repo to set public vars
| repository: ${{ env.REPOSITORY_URL }} | ||
| ref: ${{ env.BRANCH }} |
There was a problem hiding this comment.
They do not have real difference, but in Github action docs, it said that:
"Runner environment variables are always interpolated on the runner machine. However, parts of a workflow are processed by GitHub Actions and are not sent to the runner. You cannot use environment variables in these parts of a workflow file. Instead, you can use contexts. For example, an if conditional, which determines whether a job or step is sent to the runner, is always processed by GitHub Actions. You can use a context in an if conditional statement to access the value of an variable."
It mease that we can not directly use $BRANCH in these parts like "if" or "with", and we must use env context to get them. Because they are processed by github action, but not runner machine. You can not use $BRANCH to get the value. In github action, there is not $BRANCH, but only the env context or other context.
But in "run statement", these vars are sent to runner machine instead of github action, where we can use $BRANCH directly to get the value.
BTW, in "if conditional statement", use ${{ }} seems to be the recommended way, I have fixed it.
| -d '{"name":"'"$var_name"'","value":"'"$current_commit_hash"'"}' | ||
| -H "Authorization: Bearer $GITHUB_TOKEN" \ | ||
| https://api.github.com/repos/$OWNER/$REPO/actions/variables/LAST_COMMIT_HASH \ | ||
| -d '{"name":"LAST_COMMIT_HASH","value":"'"$CURRENT_COMMIT_HASH"'"}' No newline at end of file |
There was a problem hiding this comment.
I develop on remote server with vsc remote-ssh plugin, and there is no copy on my local machine. Github desktop can not deal with the case.
Is there any recommended plugin to check problem like these?
| REPOSITORY_URL: apache/hugegraph | ||
| BRANCH: master | ||
| IMAGE_URL: hugegraph/hugegraph:latest | ||
| GITHUB_TOKEN: ${{ secrets.PAT }} |


Purpose of PR
subtask of apache/hugegraph#840
Main change
Api reference: This api help us to update the github repo var Update a repository variable
old desgin doc: apache/hugegraph#2254
new design doc: extra design doc
new change
Before Merge
Create a branch in apache/hugegraph repo, then I can submit a pr of the release-1.0.0 with correct dockerfile and other shell. it needs the admin to create.
Before merge, admin should confirm that there are the repository secrets "DOCKERHUB_PASSWORD", "DOCKERHUB_USERNAME", "PAT" are provided, where "PAT" is a token accessible to the repo.
Repository variables "LATEST_SHA" should be provided. Because there is no "create an update" api, "LATEST_SHA" are necessary.